UInt16.MinValue UInt16.MinValue UInt16.MinValue UInt16.MinValue Field

定義

代表 UInt16 最小的可能值。Represents the smallest possible value of UInt16. 這個欄位是常數。This field is constant.

public: System::UInt16 MinValue = 0;
public const ushort MinValue = 0;
val mutable MinValue : uint16
Public Const MinValue As UShort  = 0

欄位值

範例

下列範例會使用MinValueMaxValue Int32屬性,以確保值在UInt16類型的範圍內,再轉換為UInt16值。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. OverflowException如果整數值不在UInt16類型的範圍內,這可防止轉換作業擲回。This prevents the conversion operation from throwing an OverflowException if the integer value is not in the range of the UInt16 type.

int integerValue = 1216; 
ushort uIntegerValue;

if (integerValue >= ushort.MinValue & integerValue <= ushort.MaxValue)
{
   uIntegerValue = (ushort) integerValue;
   Console.WriteLine(uIntegerValue);
} 
else
{
   Console.WriteLine("Unable to convert {0} to a UInt16t.", integerValue);
}     
Dim integerValue As Integer = 1216
Dim uIntegerValue As UShort

If integerValue >= UShort.MinValue And integerValue <= UShort.MaxValue Then
   uIntegerValue = CUShort(integerValue) 
   Console.WriteLine(uIntegerValue)
Else
   Console.WriteLine("Unable to convert {0} to a UInt16t.", integerValue)   
End If   

備註

這個常數的值是0。The value of this constant is 0.

適用於

另請參閱