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
| Field | Description |
|---|---|
MaxValue | The largest possible value of UInt32. |
MinValue | The smallest possible value of UInt32 (0). |
Methods
| Method | Signature | Summary |
|---|---|---|
Parse | static UInt32 Parse(string s) | Converts the string representation of a number to its UInt32 equivalent. |
TryParse | static bool TryParse(string s, out UInt32 result) | Attempts to convert the string representation of a number to its UInt32 equivalent. |
ToString | string ToString() | Formats the value of this instance using the default format. |
CompareTo | int 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.");
}