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.

适用于

另请参阅