#39 – MinValue / MaxValue for Numeric Types

You can access minimum and maximum values for the various built-in numeric types from your code by using the MinValue and MaxValue properties of each type.  All of the built-in numeric types have MinValue and MaxValue properties.

 byte bMin = byte.MinValue;    // 0
 byte bMax = byte.MaxValue;    // 255

 int nMin = int.MinValue;      // -2147483648
 int nMax = Int32.MaxValue;    // 2147483647

 char cMin = char.MinValue;    // 0x0000
 char cMax = char.MaxValue;    // 0xffff
Advertisement