System.UInt64 Structure

Assembly: Mscorlib.dll
Namespace: System
Summary
Represents a 64-bit unsigned integer.
This class is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
[Serializable]
public struct UInt64 : IComparable, IFormattable, IConvertible
Remarks
The UInt64 value type represents unsigned integers with values ranging from 0 to 184,467,440,737,095,551,615.

UInt64 provides methods to compare instances of this type, convert the value of an instance to its string representation, and convert the string representation of a number to an instance of this type.

Assigning a 64-bit value on a 32-bit Intel computer is not an atomic operation; that is, the operation is not thread safe. This means that if two people simultaneously assign a value to a static UInt64 field, the final value of the field cannot be predicted.

For information about how format specification codes control the string representation of value types, see the conceptual topic at MSDN: formattingoverview.

This type implements interfaces IComparable, IFormattable, and IConvertible. Use the Convert class for conversions instead of this type's explicit interface member implementation of IConvertible.

See also:
System Namespace | Int64

System.UInt64 Member List:

Public Fields
MaxValue Represents the largest possible value of UInt64. This field is constant.
MinValue Represents the smallest possible value of UInt64. This field is constant.
Public Methods
CompareTo Compares this instance to a specified object and returns an indication of their relative values.
Equals Overridden:
Returns a value indicating whether this instance is equal to a specified object.
GetHashCode Overridden:
Returns the hash code for this instance.
GetType
(inherited from System.Object)
See base class member description: System.Object.GetType

Derived from System.Object, the primary base class for all objects.
GetTypeCode Returns the TypeCode for value type UInt64.
Parse Overloaded:
Parse(string s)

Converts the string representation of a number to its 64-bit unsigned integer equivalent.
Parse Overloaded:
Parse(string s, IFormatProvider provider)

Converts the string representation of a number in a specified culture-specific format to its 64-bit unsigned integer equivalent.
Parse Overloaded:
Parse(string s, NumberStyles style)

Converts the string representation of a number in a specified style to its 64-bit unsigned integer equivalent.
Parse Overloaded:
Parse(string s, NumberStyles style, IFormatProvider provider)

Converts the string representation of a number in a specified style and culture-specific format to its 64-bit unsigned integer equivalent.
ToString Overloaded:
ToString()

Overridden:
Converts the numeric value of this instance to its equivalent string representation.
ToString Overloaded:
ToString(IFormatProvider provider)

Converts the numeric value of this instance to its equivalent string representation using the specified culture-specific format information.
ToString Overloaded:
ToString(string format)

Converts the numeric value of this instance to its equivalent string representation using the specified format.
ToString Overloaded:
ToString(string format, IFormatProvider provider)

Converts the numeric value of this instance to its equivalent string representation using the specified format and culture-specific format information.
Protected Methods
Finalize
(inherited from System.Object)
See base class member description: System.Object.Finalize

Derived from System.Object, the primary base class for all objects.
MemberwiseClone
(inherited from System.Object)
See base class member description: System.Object.MemberwiseClone

Derived from System.Object, the primary base class for all objects.

Hierarchy:


System.UInt64 Member Details

Field: MaxValue
Summary
Represents the largest possible value of UInt64. This field is constant.
This class is not CLS Compliant

C# Syntax:
public const ulong MaxValue;
Remarks
The value of this constant is 18,446,744,073,709,551,615; that is, hexadecimal 0xFFFFFFFFFFFFFFFF.
See also:
UInt64.MinValue

Return to top


Field: MinValue
Summary
Represents the smallest possible value of UInt64. This field is constant.
This class is not CLS Compliant

C# Syntax:
public const ulong MinValue;
Remarks
The value of this constant is 0.
See also:
UInt64.MaxValue

Return to top


Method: CompareTo(
   object value
)
Summary
Compares this instance to a specified object and returns an indication of their relative values.
This class is not CLS Compliant

C# Syntax:
public int CompareTo(
   object value
);
Parameters:

value

An object to compare, or null.

Return Value:
A signed number indicating the relative values of this instance and value.

Return Value Description
Less than zero This instance is less than .
Zero This instance is equal to .
Greater than zero This instance is greater than value. -or- value is null.
Exceptions
Exception Type Condition
ArgumentException value is not a UInt64.
Remarks
Any instance of UInt64, regardless of its value, is considered greater than null.

value must be null or an instance of UInt64; otherwise, an exception is thrown.

See also:
UInt64.Equals

Return to top


Overridden Method: Equals(
   object obj
)
Summary
Returns a value indicating whether this instance is equal to a specified object.
This class is not CLS Compliant

C# Syntax:
public override bool Equals(
   object obj
);
Parameters:

obj

An object to compare with this instance.

Return Value:
true if obj is an instance of UInt64 and equals the value of this instance; otherwise, false.
Example
The sample demonstrates the UInt64.Equals method.
            UInt64 myVariable1 = 50;
            UInt64 myVariable2 = 50;

            // Display the declaring type.
            Console.WriteLine("\nType of 'myVariable1' is '{0}' and"+
                 " value is :{1}",myVariable1.GetType(), myVariable1); 
            Console.WriteLine("Type of 'myVariable2' is '{0}' and"+
                 " value is :{1}",myVariable2.GetType(), myVariable2);
            // Compare 'myVariable1' instance with 'myVariable2' Object.
            if( myVariable1.Equals( myVariable2 ) )
               Console.WriteLine( "\nStructures 'myVariable1' and "+
                     "'myVariable2' are equal");
            else
               Console.WriteLine( "\nStructures 'myVariable1' and "+
                     "'myVariable2' are not equal");

    
See also:
UInt64.CompareTo

Return to top


Method: Finalize()
Inherited
See base class member description: System.Object.Finalize
This class is not CLS Compliant

C# Syntax:
~UInt64();

For more information on members inherited from System.Object click on the link above.

Return to top


Overridden Method: GetHashCode()
Summary
Returns the hash code for this instance.
This class is not CLS Compliant

C# Syntax:
public override int GetHashCode();
Return Value:
A 32-bit signed integer hash code.

Return to top


Method: GetType()
Inherited
See base class member description: System.Object.GetType
This class is not CLS Compliant

C# Syntax:
public Type GetType();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetTypeCode()
Summary
Returns the TypeCode for value type UInt64.
This class is not CLS Compliant

C# Syntax:
public TypeCode GetTypeCode();
Return Value:
The enumerated constant, TypeCode.UInt64.
See also:
TypeCode

Return to top


Method: MemberwiseClone()
Inherited
See base class member description: System.Object.MemberwiseClone
This class is not CLS Compliant

C# Syntax:
protected object MemberwiseClone();

For more information on members inherited from System.Object click on the link above.

Return to top


Overloaded Method: Parse(
   string s
)
Summary
Converts the string representation of a number to its 64-bit unsigned integer equivalent.
This class is not CLS Compliant

This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ulong Parse(
   string s
);
Parameters:

s

A string representing the number to convert.

Return Value:
A 64-bit unsigned integer equivalent to the number contained in s.
Exceptions
Exception Type Condition
ArgumentNullException The s parameter is null.
FormatException The s parameter is not of the correct format.
OverflowException The s parameter represents a number less than UInt64.MinValue or greater than UInt64.MaxValue.
Remarks
The s parameter contains a number of the form:

[ws][sign]digits[ws]

Items in square brackets ('[' and ']') are optional, and other items are as follows.

ws Optional white space. sign An optional positive sign. digits A sequence of digits ranging from 0 to 9.

The s parameter is parsed using the formatting information in a NumberFormatInfo initialized for the current system culture. For more information, see NumberFormatInfo.CurrentInfo.

See also:
MSDN: formattingoverview | UInt64.ToString

Return to top


Overloaded Method: Parse(
   string s,
   IFormatProvider provider
)
Summary
Converts the string representation of a number in a specified culture-specific format to its 64-bit unsigned integer equivalent.
This class is not CLS Compliant

This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ulong Parse(
   string s,
   IFormatProvider provider
);
Parameters:

s

A string representing the number to convert.

provider

An IFormatProvider that supplies culture-specific formatting information about s.

Return Value:
A 64-bit unsigned integer equivalent to the number specified in s.
Exceptions
Exception Type Condition
ArgumentNullException The s parameter is null.
FormatException The s parameter is not in the correct style.
OverflowException The s parameter represents a number less than UInt64.MinValue or greater than UInt64.MaxValue.
Remarks
The s parameter contains a number of the form:

[ws][sign]digits[ws]

Items in square brackets ('[' and ']') are optional, and other items are as follows.

ws Optional white space. sign An optional positive sign. digits A sequence of digits ranging from 0 to 9.

The provider parameter is an IFormatProvider that obtains a NumberFormatInfo. The NumberFormatInfo provides culture-specific information about the format of s. If provider is null, the NumberFormatInfo for the current culture is used.

See also:
MSDN: formattingoverview | UInt64.ToString

Return to top


Overloaded Method: Parse(
   string s,
   NumberStyles style
)
Summary
Converts the string representation of a number in a specified style to its 64-bit unsigned integer equivalent.
This class is not CLS Compliant

This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ulong Parse(
   string s,
   NumberStyles style
);
Parameters:

s

A string representing the number to convert.

style

The combination of one or more NumberStyles constants that indicate the permitted format of s.

Return Value:
A 64-bit unsigned integer equivalent to the number specified in s.
Exceptions
Exception Type Condition
ArgumentNullException The s parameter is null.
ArgumentException The style parameter is not a valid combination of bit flags from the NumberStyles enumeration.
FormatException The s parameter is not in a format compliant with style.
OverflowException The s parameter represents a number less than UInt64.MinValue or greater than UInt64.MaxValue.
Remarks
The s parameter contains a number of the form:

[ws][sign]digits[ws]

Items in square brackets ('[' and ']') are optional, and other items are as follows.

ws Optional white space. sign An optional positive sign. digits A sequence of digits ranging from 0 to 9.

The style parameter can be one or more NumberStyles enumerated constants combined using a bitwise OR operation (except NumberStyles.Any and NumberStyles.AllowDecimalPoint, which are invalid for the type returned by this method).

See also:
MSDN: formattingoverview | UInt64.ToString

Return to top


Overloaded Method: Parse(
   string s,
   NumberStyles style,
   IFormatProvider provider
)
Summary
Converts the string representation of a number in a specified style and culture-specific format to its 64-bit unsigned integer equivalent.
This class is not CLS Compliant

This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ulong Parse(
   string s,
   NumberStyles style,
   IFormatProvider provider
);
Parameters:

s

A string representing the number to convert.

style

The combination of one or more NumberStyles constants that indicate the permitted format of s.

provider

An IFormatProvider that supplies culture-specific formatting information about s.

Return Value:
A 64-bit unsigned integer equivalent to the number specified in s.
Exceptions
Exception Type Condition
ArgumentNullException The s parameter is null.
ArgumentException The style parameter is not a valid combination of NumberStyles enumerated constants.
FormatException The s parameter is not in a format compliant with style.
OverflowException The s parameter represents a number less than UInt64.MinValue or greater than UInt64.MaxValue.
Remarks
The s parameter contains a number of the form:

[ws][sign]digits[ws]

Items in square brackets ('[' and ']') are optional, and other items are as follows.

ws Optional white space. sign An optional positive sign. digits A sequence of digits ranging from 0 to 9.

The style parameter can be one or more NumberStyles enumerated constants combined using a bitwise OR operation (except NumberStyles.Any and NumberStyles.AllowDecimalPoint, which are invalid for the type returned by this method).

The provider parameter is an IFormatProvider that obtains a NumberFormatInfo. The NumberFormatInfo provides culture-specific information about the format of s. If provider is null, the NumberFormatInfo for the current culture is used.

See also:
MSDN: formattingoverview | UInt64.ToString

Return to top


Overloaded Method: ToString()
Summary
Converts the numeric value of this instance to its equivalent string representation.
This class is not CLS Compliant

C# Syntax:
public override string ToString();
Return Value:
The string representation of the value of this instance, consisting of a sequence of digits ranging from 0 to 9, without a sign or leading zeroes.
Remarks
The return value is formatted with the general format specifier ("G") and the NumberFormatInfo for the current culture.
See also:
MSDN: formattingoverview | UInt64.Parse | String

Return to top


Overloaded Method: ToString(
   IFormatProvider provider
)
Summary
Converts the numeric value of this instance to its equivalent string representation using the specified culture-specific format information.
This class is not CLS Compliant

C# Syntax:
public string ToString(
   IFormatProvider provider
);
Parameters:

provider

An IFormatProvider that supplies culture-specific formatting information.

Return Value:
The string representation of the value of this instance as specified by provider.
Remarks
This instance is formatted with the general format specifier ("G").

The provider parameter is an IFormatProvider that obtains a NumberFormatInfo. The NumberFormatInfo provides culture-specific format information about this instance. If provider is null, this instance is formatted with the NumberFormatInfo for the current culture.

See also:
MSDN: formattingoverview | UInt64.Parse | String

Return to top


Overloaded Method: ToString(
   string format
)
Summary
Converts the numeric value of this instance to its equivalent string representation using the specified format.
This class is not CLS Compliant

C# Syntax:
public string ToString(
   string format
);
Parameters:

format

A format string.

Return Value:
The string representation of the value of this instance as specified by format.
Exceptions
Exception Type Condition
FormatException The format parameter is invalid.
Remarks
If format is null or an empty string (""), the return value of this instance is formatted with the general format specifier ("G").

The return value of this instance is formatted with the NumberFormatInfo for the current culture.

See also:
MSDN: formattingoverview | UInt64.Parse | String

Return to top


Overloaded Method: ToString(
   string format,
   IFormatProvider provider
)
Summary
Converts the numeric value of this instance to its equivalent string representation using the specified format and culture-specific format information.
This class is not CLS Compliant

C# Syntax:
public string ToString(
   string format,
   IFormatProvider provider
);
Parameters:

format

A format specification.

provider

An IFormatProvider that supplies culture-specific formatting information about this instance.

Return Value:
The string representation of the value of this instance as specified by format and provider.
Exceptions
Exception Type Condition
FormatException The format parameter is invalid.
Remarks
If format is null or an empty string (""), the return value for this instance is formatted with the general format specifier ("G").

The provider parameter is an IFormatProvider that obtains a NumberFormatInfo. The NumberFormatInfo provides culture-specific format information about this instance. If provider is null, the return value for this instance is formatted with the NumberFormatInfo for the current culture.

See also:
MSDN: formattingoverview | UInt64.Parse | String

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.