UInt64.MinValue UInt64.MinValue UInt64.MinValue UInt64.MinValue Field

定義

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

public: System::UInt64 MinValue = 0;
public const ulong MinValue = 0;
val mutable MinValue : uint64
Public Const MinValue As ULong  = 0

フィールド値

次の例では、MinValueMaxValueことを確認するフィールドをDouble値の範囲内では、UInt64型変換を実行する前に入力します。The following example uses the MinValue and MaxValue fields to verify that a Double value is within the range of the UInt64 type before it performs a type conversion. これにより、OverflowException実行時にします。This prevents an OverflowException at run time.

double decimalValue = -1.5;
ulong integerValue; 

// Discard fractional portion of Double value
double decimalInteger = Math.Floor(decimalValue);

if (decimalInteger <= ulong.MaxValue && 
    decimalInteger >= ulong.MinValue)
{    
   integerValue = (ulong) decimalValue;
   Console.WriteLine("Converted {0} to {1}.", decimalValue, integerValue);
}   
else
{
   ulong rangeLimit;
   string relationship;
   
   if (decimalInteger > ulong.MaxValue)
   {
      rangeLimit = ulong.MaxValue;
      relationship = "greater";
   }   
   else
   {
      rangeLimit = ulong.MinValue;
      relationship = "less";
   }       

   Console.WriteLine("Conversion failure: {0} is {1} than {2}.",  
                     decimalInteger, 
                     relationship, 
                     rangeLimit);
}       
Dim decimalValue As Double = -1.5
Dim integerValue As ULong 

' Discard fractional portion of Double value
Dim decimalInteger As Double = Math.Floor(decimalValue)

If decimalInteger <= ULong.MaxValue AndAlso _
   decimalInteger >= ULong.MinValue Then
   integerValue = CULng(decimalValue)
   Console.WriteLine("Converted {0} to {1}.", decimalValue, integerValue)
Else
   Dim rangeLimit As ULong
   Dim relationship As String
   
   If decimalInteger > ULong.MaxValue Then
      rangeLimit = ULong.MaxValue
      relationship = "greater"
   Else
      rangeLimit = ULong.MinValue
      relationship = "less"
   End If       

   Console.WriteLine("Conversion failure: {0} is {1} than {2}", _ 
                     decimalInteger, _
                     relationship, _
                     rangeLimit)
End If       

注釈

この定数の値は 0 です。The value of this constant is 0.

適用対象

こちらもご覧ください