Get Numeric type ranges - CSharp Language Basics

CSharp examples for Language Basics:Data Type

Description

Get Numeric type ranges

Demo Code

using System;//from  w ww.ja va2 s . c  o  m
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program
{
   static void Main(string[] args)
   {
      // Immediately outputs
      Console.WriteLine("Signed whole numbers");
      Console.WriteLine("sbyte:  " + sbyte.MinValue + " to " + sbyte.MaxValue);
      Console.WriteLine("short:  " + short.MinValue + " to " + short.MaxValue);
      Console.WriteLine("int:    " + int.MinValue + " to " + int.MaxValue);
      Console.WriteLine("long:   " + long.MinValue + " to " + long.MaxValue);
      Console.WriteLine();
      Console.WriteLine("Unsigned whole numbers");
      Console.WriteLine("byte:   " + byte.MinValue + " to " + byte.MaxValue);
      Console.WriteLine("ushort: " + ushort.MinValue + " to " + ushort.MaxValue);
      Console.WriteLine("unit:   " + uint.MinValue + " to " + uint.MaxValue);
      Console.WriteLine("ulong:  " + ulong.MinValue + " to " + ulong.MaxValue);
      Console.WriteLine();
      Console.WriteLine("Basic decimal numbers");
      Console.WriteLine("float:  " + float.MinValue + " to " + float.MaxValue);
      Console.WriteLine("double: " + double.MinValue + " to " + double.MaxValue);
      Console.WriteLine();
      Console.WriteLine("Exact decimal numbers");
      Console.WriteLine("decimal:  " + decimal.MinValue + " to " + decimal.MaxValue);
   }
}

Result


Related Tutorials