System.UInt32 Structure

Represents a 32-bit unsigned integer.

Syntax

public struct UInt32 : IComparable, IConvertible, IComparable<UInt32>, IEquatable<UInt32>, IFormattable

Remarks

UInt32 is an alias for System.UInt32. It provides a range of 0 to 4,294,967,295 inclusive.

Fields

FieldDescription
MaxValueThe largest possible value of UInt32.
MinValueThe smallest possible value of UInt32 (0).

Methods

MethodSignatureSummary
Parsestatic UInt32 Parse(string s)Converts the string representation of a number to its UInt32 equivalent.
TryParsestatic bool TryParse(string s, out UInt32 result)Attempts to convert the string representation of a number to its UInt32 equivalent.
ToStringstring ToString()Formats the value of this instance using the default format.
CompareToint CompareTo(Object value)Compares this instance to a specified object and returns an indication of their relative values.

Example

// Convert a string to UInt32 and display it.
string numberString = "4294967295";
if (UInt32.TryParse(numberString, out UInt32 value))
{
    Console.WriteLine($"Parsed value: {value}");
    Console.WriteLine($"Hexadecimal: 0x{value:X8}");
    Console.WriteLine($"Binary: {Convert.ToString(value, 2).PadLeft(32, '0')}");
}
else
{
    Console.WriteLine("Invalid number.");
}

See also

Toggle Dark Mode