Struct System.UInt32
Fields
MaxValue
public const uint MaxValue = 4294967295;Represents the largest possible value of a uint
. This field is constant.
uint
MinValue
public const uint MinValue = 0;Represents the smallest possible value of a uint
. This field is constant.
uint
Methods
CompareTo
public int CompareTo(uint value)Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
int
Equals
public bool Equals(uint obj)Returns a value indicating whether this instance is equal to a specified object.
bool
Parse
public static uint Parse(string s)Converts the string representation of a number to its 32-bit unsigned integer equivalent.
uint
ToString
public override string ToString()Converts the numeric value of this instance to its equivalent string representation.
string
TryParse
public static bool TryParse(string s, out uint result)Converts the string representation of a number to its 32-bit unsigned integer equivalent. A return value indicates whether the conversion succeeded or failed.
bool
Properties
IsEven
public bool IsEven { get; }Gets a value indicating whether the current unsigned integer is even.
bool
IsOdd
public bool IsOdd { get; }Gets a value indicating whether the current unsigned integer is odd.
bool
Implicit Conversion Operators
uint from int
public static implicit operator uint(int value)Converts an int
to a uint
.
uint from string
public static implicit operator uint(string value)Converts a string representation of a number to a uint
.
Examples
using System;
public class Example
{
public static void Main()
{
uint maxValue = uint.MaxValue;
uint minValue = uint.MinValue;
uint myNumber = 100;
Console.WriteLine($"Maximum unsigned integer: {maxValue}");
Console.WriteLine($"Minimum unsigned integer: {minValue}");
Console.WriteLine($"My number: {myNumber}");
if (myNumber.IsEven)
{
Console.WriteLine($"{myNumber} is an even number.");
}
string numString = "255";
if (uint.TryParse(numString, out uint parsedNumber))
{
Console.WriteLine($"Successfully parsed '{numString}' to {parsedNumber}");
}
}
}