#39 – MinValue / MaxValue for Numeric Types
July 26, 2010 2 Comments
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
“All of the built-in numeric types have MinValue and MaxValue properties.” did you mean value types instead of numeric types. I think char is not a numeric type, or am i missing something?
No, I did mean numeric types. It’s true that all numeric types have MinValue and MaxValue properties, as does the char type.