Convert.ToUInt16 (Decimal) converts decimal number to 16-bit unsigned integer.
Class Sample
Public Shared Sub Main()
Dim values() As Decimal = { Decimal.MinValue, -111111.23d}
Dim result As UShort
For Each value As Decimal In values
Try
result = Convert.ToUInt16(value)
Console.WriteLine("Converted the {0} value '{1}' to the {2} value {3}.", _
value.GetType().Name, value, _
result.GetType().Name, result)
Catch e As OverflowException
Console.WriteLine("{0} is outside the range of the UInt16 type.", _
value)
End Try
Next
End Sub
End Class
Related examples in the same category