UInt32.MaxValue Field
.NET Framework 4.5
Represents the largest possible value of UInt32. This field is constant.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
The following example uses the MinValue and MaxValue fields to verify that an Int64 value is within the range of the UInt32 type before it performs a type conversion. This verification prevents an OverflowException at run time.
long longValue = long.MaxValue / 2; uint integerValue; if (longValue <= uint.MaxValue && longValue >= uint.MinValue) { integerValue = (uint) longValue; Console.WriteLine("Converted long integer value to {0:n0}.", integerValue); } else { uint rangeLimit; string relationship; if (longValue > uint.MaxValue) { rangeLimit = uint.MaxValue; relationship = "greater"; } else { rangeLimit = uint.MinValue; relationship = "less"; } Console.WriteLine("Conversion failure: {0:n0} is {1} than {2:n0}", longValue, relationship, rangeLimit); }
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.