UInt16.MinValue フィールド

定義

UInt16 の最小有効値を表します。 このフィールドは定数です。

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

フィールド値

Value = 0

次の例では、 MinValue プロパティと MaxValue プロパティを使用して、値をInt32値に変換するUInt16前に、その値がUInt16型の範囲内にあることを確認します。 これにより、整数値が型の範囲内UInt16にない場合、変換操作で がスローOverflowExceptionされなくなります。

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);
}
open System

let integerValue = 1216

if integerValue >= int UInt16.MinValue && integerValue <= int UInt16.MaxValue then
    let uIntegerValue = uint16 integerValue
    printfn $"{uIntegerValue}"
else
    printfn $"Unable to convert {integerValue} to a UInt16t."
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 です。

適用対象

こちらもご覧ください