UInt64.MaxValue Field
.NET Framework 4.5
Represents the largest possible value of UInt64. This field is constant.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
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. 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); }
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.