MaxValue Field
Collapse the table of content
Expand the table of content

UInt16.MaxValue Field

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Represents the largest possible value of UInt16. This field is constant.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

'Declaration
Public Const MaxValue As UShort

The value of this constant is 65535; that is, hexadecimal 0xFFFF.

The following example uses the MaxValue and MinValue properties to ensure that an Int32 value is in the range of the UInt16 type before converting it to a UInt16 value. This prevents the conversion operation from throwing an OverflowException if the integer value is not in the range of the UInt16 type.


Dim integerValue As Integer = 1216
Dim uIntegerValue As UShort

If integerValue >= UShort.MinValue And integerValue <= UShort.MaxValue Then
   uIntegerValue = CUShort(integerValue)
   outputBlock.Text += CStr(uIntegerValue) + vbCrLf
Else
   outputBlock.Text += String.Format("Unable to convert {0} to a UInt16t.", integerValue) + vbCrLf
End If


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft