C# 数値の型名 MIN MAX を表示してみた。型のメンバに定義を持っているので、意外とうまく表示出来た。表示形式は、はてな記法に決め打ちしたコードになっているが・・・。
Sample Code(サンプルコード)
Debug.WriteLine("|{0}|{1}|{2}|{3}|","Type","SystemType","Min","Max"); Debug.WriteLine("|{0}|{1}|{2}|{3}|","float",typeof(float),float.MinValue,float.MaxValue); Debug.WriteLine("|{0}|{1}|{2}|{3}|","double",typeof(double),double.MinValue,double.MaxValue); Debug.WriteLine("|{0}|{1}|{2}|{3}|","byte",typeof(byte),byte.MinValue,byte.MaxValue); Debug.WriteLine("|{0}|{1}|{2}|{3}|","sbyte",typeof(sbyte),sbyte.MinValue,sbyte.MaxValue); Debug.WriteLine("|{0}|{1}|{2}|{3}|","short",typeof(short),short.MinValue,short.MaxValue); Debug.WriteLine("|{0}|{1}|{2}|{3}|","ushort",typeof(ushort),ushort.MinValue,ushort.MaxValue); Debug.WriteLine("|{0}|{1}|{2}|{3}|","int",typeof(int),int.MinValue,int.MaxValue); Debug.WriteLine("|{0}|{1}|{2}|{3}|","uint",typeof(uint),uint.MinValue,uint.MaxValue); Debug.WriteLine("|{0}|{1}|{2}|{3}|","long",typeof(long),long.MinValue,long.MaxValue); Debug.WriteLine("|{0}|{1}|{2}|{3}|","ulong",typeof(ulong),ulong.MinValue,ulong.MaxValue); Debug.WriteLine("|{0}|{1}|{2}|{3}|","decimal",typeof(decimal),decimal.MinValue,decimal.MaxValue);
Result(実行結果)
Type | SystemType | Min | Max |
float | System.Single | -3.402823E+38 | 3.402823E+38 |
double | System.Double | -1.79769313486232E+308 | 1.79769313486232E+308 |
byte | System.Byte | 0 | 255 |
sbyte | System.SByte | -128 | 127 |
short | System.Int16 | -32768 | 32767 |
ushort | System.UInt16 | 0 | 65535 |
int | System.Int32 | -2147483648 | 2147483647 |
uint | System.UInt32 | 0 | 4294967295 |
long | System.Int64 | -9223372036854775808 | 9223372036854775807 |
ulong | System.UInt64 | 0 | 18446744073709551615 |
decimal | System.Decimal | -79228162514264337593543950335 | 79228162514264337593543950335 |