Different Data Types and their range in C#.Net

 

There are different data types in C#.Net. Each data type has its own range of values. Below you can find C# data types, their corresponding IL(Intermediate Language) types and its range of values.

C# TypeIL TypeRange
byte System.Byte 0 to 255
short System.Int16 -32768 to 32767
int System.Int32 -2^31 to 2^31-1
long System.Int64 -2^63 to 2^63-1
sbyte System.Sbyte -128 to 127
ushort System.UInt16 0 to 65535
uint System.UInt32 0 to 2^32-1
ulong System.UInt64 0 to 2^64-1
float System.Single 4 bytes
double System.Double 8 bytes
decimal System.Decimal 16 bytes
bool System.Boolean true or false
char System.Char 2 bytes
string System.String  
object System.Object  

 

As shown above byte, ushort and ulong data types can store only unsigned values(only positive values) whereas short, int, long and sbyte types can store both signed and unsigned values(both positive and negative) within their range.

The size of the char data type has been increased to 2 bytes in C# 4.0 to provide support for Unicode characters(characters other than English), which are also represented with numeric values known as Unicode value like ASCII values for English characters. Unicode characters required 2 bytes of memory for storage. String data type length varies depends on the number of characters it stores.

Object is the parent of all the data types which can store any type of value whether it is int, string, char....etc and this is also has variable length depending on its value.