Freigeben über


UInt16.MinValue Field

Microsoft Silverlight will reach end of support after October 2021. Learn more.

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

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

Syntax

'Declaration
Public Const MinValue As UShort
public const ushort MinValue

Remarks

The value of this constant is 0.

Examples

The following example uses the MinValue and MaxValue 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
int integerValue = 1216;
ushort uIntegerValue;

if (integerValue >= ushort.MinValue & integerValue <= ushort.MaxValue)
{
   uIntegerValue = (ushort)integerValue;
   outputBlock.Text += uIntegerValue + "\n";
}
else
{
   outputBlock.Text += String.Format("Unable to convert {0} to a UInt16t.", integerValue) + "\n";
}

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.