UInt16.MaxValue UInt16.MaxValue UInt16.MaxValue UInt16.MaxValue Field

定義

UInt16 の最大有効値を表します。Represents the largest possible value of UInt16. このフィールドは定数です。This field is constant.

public: System::UInt16 MaxValue = 65535;
public const ushort MaxValue = 65535;
val mutable MaxValue : uint16
Public Const MaxValue As UShort  = 65535

フィールド値

次の例では、UInt16.MaxValueUInt16.MinValueことを確認するプロパティ、Int32値の範囲では、UInt16型に変換する前に、UInt16値。The following example uses the UInt16.MaxValue and UInt16.MinValue 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   

注釈

この定数の値は 65535 です。つまり、16 進数 0 xffff です。The value of this constant is 65535; that is, hexadecimal 0xFFFF.

適用対象

こちらもご覧ください