Covers topics on the Microsoft Certification Exam for the .NET Framework (Exam 70-536, Microsoft .NET Framework - Application Development Foundation)

Saturday, March 8, 2008

Range of built-in value types

The code snippet below will display the minimum and maximum values of the built in value types in the .NET Framework.


Console.WriteLine("Built-in value type ranges");

Console.WriteLine("SByte Min: " + System.SByte.MinValue + " Max: " + System.SByte.MaxValue);
Console.WriteLine("Byte Min: " + System.Byte.MinValue + " Max: " + System.Byte.MaxValue);
Console.WriteLine("Int16 Min: " + System.Int16.MinValue + " Max: " + System.Int16.MaxValue);
Console.WriteLine("Int32 Min: " + System.Int32.MinValue + " Max: " + System.Int32.MaxValue);
Console.WriteLine("Int64 Min: " + System.Int64.MinValue + " Max: " + System.Int64.MaxValue);
Console.WriteLine("Single Min: " + System.Single.MinValue + " Max: " + System.Single.MaxValue);
Console.WriteLine("Double Min: " + System.Double.MinValue + " Max: " + System.Double.MaxValue);
Console.WriteLine("Decimal Min: " + System.Decimal.MinValue + " Max: " + System.Decimal.MaxValue);


After you run the application you get the following output:
Built-in value type ranges
SByte Min: -128 Max: 127
Byte Min: 0 Max: 255
Int16 Min: -32768 Max: 32767
Int32 Min: -2147483648 Max: 2147483647
Int64 Min: -9223372036854775808 Max: 9223372036854775807
Single Min: -3.402823E+38 Max: 3.402823E+38
Double Min: -1.79769313486232E+308 Max: 1.79769313486232E+308
Decimal Min: -79228162514264337593543950335 Max: 79228162514264337593543950335
Additional Resources
TypeRanges Source

No comments:

Support This Site

LinkShare  Referral  Prg