This documentation is archived and is not being maintained.

UInt64.MaxValue Field

Represents the largest possible value of UInt64. This field is constant.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

Public Const MaxValue As ULong

The value of this constant is 18,446,744,073,709,551,615; that is, hexadecimal 0xFFFFFFFFFFFFFFFF.

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.

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)
   Dim rangeLimit As ULong
   Dim relationship As String

   If decimalInteger > ULong.MaxValue Then
      rangeLimit = ULong.MaxValue
      relationship = "greater"
      rangeLimit = ULong.MinValue
      relationship = "less"
   End If       

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

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.