次の方法で共有


UInt32.MaxValue Field

Microsoft Silverlight will reach end of support after October 2021. Learn more.

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

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

Syntax

'Declaration
Public Const MaxValue As UInteger
public const uint MaxValue

Remarks

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

Examples

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.

Dim longValue As Long = Long.MaxValue \ 2
Dim integerValue As UInteger

If longValue <= UInteger.MaxValue AndAlso _
   longValue >= UInteger.MinValue Then
   integerValue = CUInt(longValue)
   outputBlock.Text += String.Format("Converted long integer value to {0:n0}.", _
                     integerValue) + vbCrLf
Else
   Dim rangeLimit As UInteger
   Dim relationship As String

   If longValue > UInteger.MaxValue Then
      rangeLimit = UInteger.MaxValue
      relationship = "greater"
   Else
      rangeLimit = UInteger.MinValue
      relationship = "less"
   End If

   outputBlock.Text += String.Format("Conversion failure: {0:n0} is {1} than {2:n0}.", _
                     longValue, _
                     relationship, _
                     rangeLimit) + vbCrLf
End If
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";
}

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.