This documentation is archived and is not being maintained.

Byte.MaxValue Field

Represents the largest possible value of a Byte. This field is constant.

[Visual Basic]
Public Const MaxValue As Byte
[C#]
public const byte MaxValue;
[C++]
public: const unsigned char MaxValue;
[JScript]
public var MaxValue : Byte;

Remarks

The value of this constant is 255 (hexadecimal 0xFF).

Example

[Visual Basic] 
Public Sub MinMaxFields(ByVal numberToSet As Integer)
   If numberToSet <= CInt([Byte].MaxValue) And numberToSet >= CInt([Byte].MinValue) Then
      ' You must explicitly convert an integer to a byte.
      MemberByte = CType(numberToSet, [Byte])

      ' Displays MemberByte using the ToString() method.
      Console.WriteLine("The MemberByte value is {0}", MemberByte.ToString())
   Else
      Console.WriteLine("The value {0} is outside of the range of possible Byte values", numberToSet.ToString())
   End If
End Sub 'MinMaxFields


[C#] 
public void MinMaxFields(int numberToSet)
{
   if(numberToSet <= (int)Byte.MaxValue && numberToSet >= (int)Byte.MinValue)
   {
      // You must explicitly convert an integer to a byte.
      MemberByte = (Byte)numberToSet;

      // Displays MemberByte using the ToString() method.
      Console.WriteLine("The MemberByte value is {0}", MemberByte.ToString());
   }
   else
   {
      Console.WriteLine("The value {0} is outside of the range of possible Byte values", numberToSet.ToString());
   }
}

[C++] 
void MinMaxFields(Int32 numberToSet)
{
    if(numberToSet <= (Int32)Byte::MaxValue && numberToSet >= (Int32)Byte::MinValue)
    {
        // You must explicitly convert an integer to a byte.
        MemberByte = (Byte)numberToSet;
              
        // Displays MemberByte using the ToString() method.
        Console::WriteLine("The MemberByte value is {0}", MemberByte.ToString());
    }
    else {
        Console::WriteLine("The value {0} is outside of the range of possible Byte values", numberToSet.ToString());
    }
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

Byte Structure | Byte Members | System Namespace | MinValue

Show: