UInt64.MinValue 欄位
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
代表 UInt64 最小的可能值。 這個欄位為常數。
public: System::UInt64 MinValue = 0;
public const ulong MinValue = 0;
val mutable MinValue : uint64
Public Const MinValue As ULong = 0
欄位值
Value = 0範例
下列範例會使用 MinValue 和 MaxValue 欄位,在執行類型轉換之前, Double 先確認值在類型範圍內 UInt64 。 這會在 OverflowException 執行時間防止 。
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);
}
open System
let decimalValue = -1.5
// Discard fractional portion of Double value
let decimalInteger = floor decimalValue
if decimalInteger <= float UInt64.MaxValue && decimalInteger >= float UInt64.MinValue then
let integerValue = uint64 decimalValue
printfn $"Converted {decimalValue} to {integerValue}."
else
let rangeLimit, relationship =
if decimalInteger > float UInt64.MaxValue then
UInt64.MaxValue, "greater"
else
UInt64.MinValue, "less"
printfn $"Conversion failure: {decimalInteger} is {relationship} than {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。