MaxValue Field
Collapse the table of content
Expand the table of content

UInt32.MaxValue Field

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Represents the largest possible value of UInt32. This field is constant.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

public const uint MaxValue

The value of this constant is 4,294,967,295; that is, hexadecimal 0xFFFFFFFF.

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;
   outputBlock.Text += String.Format("Converted long integer value to {0:n0}.",
                     integerValue) + "\n";
}
else
{
   uint rangeLimit;
   string relationship;

   if (longValue > uint.MaxValue)
   {
      rangeLimit = uint.MaxValue;
      relationship = "greater";
   }
   else
   {
      rangeLimit = uint.MinValue;
      relationship = "less";
   }

   outputBlock.Text += String.Format("Conversion failure: {0:n0} is {1} than {2:n0}",
                     longValue,
                     relationship,
                     rangeLimit) + "\n";
}


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft