C# | UInt32 Struct
In C#, UInt32 struct is used to represent 32-bit unsigned integers(also termed as uint data type) starting from range 0 to 4,294,967,295. It also provides different types of methods to compare instances of this type, convert the value of an instance to its String representation, convert the String representation of a number to an instance of this type, etc. This struct is defined under System namespace. UInt32 struct inherits the ValueType class which inherits the Object class.
Fields
| Field | Description |
|---|---|
| MaxValue | Represents the largest possible value of UInt32. This field is constant. |
| MinValue | Represents the smallest possible value of UInt32. This field is constant. |
Example:
// C# program to illustrate the // fields of UInt32 struct using System; class GFG { // Main Method static public void Main() { // Unsigned 32-bit integer uint val = 4294967295; // Checking the unsigned integer if (val.Equals(UInt32.MinValue)) { Console.WriteLine("Equal to MinValue!"); } else if (val.Equals(UInt32.MaxValue)) { Console.WriteLine("Equal to MaxValue!"); } else { Console.WriteLine("Not Equal!"); } } } |
Equal to MaxValue!
Methods
| Method | Description |
|---|---|
| CompareTo() | Compares the current instance to a specified object or UInt32 and returns an indication of their relative values. |
| Equals() | Returns a value which shows whether the current instance is equal to a specified object or UInt32. |
| GetHashCode() | Returns the hash code for this instance. |
| GetTypeCode() | Returns the TypeCode for value type UInt32. |
| Parse() | Converts the string representation of a number to its 32-bit unsigned integer equivalent. |
| ToString() | Converts the numeric value of this instance to its equivalent string representation. |
| TryParse() | Tries to convert the string representation of a number to its 32-bit unsigned integer equivalent. A return value indicates whether the conversion succeeded or failed. |
Example:
// C# program to illustrate how to get the // hash code of the 32-bit Unsigned integer using System; class GFG { // Main Method static public void Main() { // UInt32 variable uint myval = 33453242; // Get the hash code // Using GetHashCode Method int res = myval.GetHashCode(); Console.WriteLine("The hash code of myval is: {0}", res); } } |
The hash code of myval is: 33453242
Reference:
Recommended Posts:
- UInt32.GetHashCode Method in C# with Examples
- UInt32.CompareTo() Method in C# with Examples
- UInt32.Equals Method in C# with Examples
- UInt32.ToString() Method in C# with Examples | Set - 1
- UInt32.GetTypeCode Method in C# with Examples
- UInt32.MaxValue Field in C# with Examples
- UInt32.MinValue Field in C# with Examples
- UInt32.ToString Method in C# with Examples | Set - 2
- UInt32.Parse(String) Method in C# with Examples
- C# | Int 64 Struct
- C# | UInt16 Struct
- C# | UInt64 Struct
- C# | ValueTuple <T1,T2,T3> Struct
- C# | ValueTuple <T1,T2,T3,T4> Struct
- C# | ValueTuple <T1,T2,T3,T4,T5> Struct
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


