Monday, 1 July 2013

Fundamentals of C# Dot Net Datatypes

Hi all,

Hope you have better knowledge about dot net framework on my previous post Understanding Dot Net Framework. Now I am going to explain C# dot net datatypes. Ok, before start I want to explain some fundamentals of data. Of course many of you already know, anyway lets start.


In the above picture computer memory represents "A" as eight bits, I mean one byte. We all know

8 bit = 1 byte
So in this way we can represents up to 

2=256 characters. 

Here range for the characters are 0 -255. In C# we have a datatype byte, it's stored exactly 0 to 255 characters. In other words It's represents ASCII.

OK, Now if we want to represents more than 256 characters, what do we do? For this C# provide another datatype char, it's takes two bytes to represents a character. When we use this char datatype, we can represents up to,

216 =65536

Here range for the characters are 0-65535. In other words, char datatype represents UNICODE. Series of char datatypes is called string. So we can categorize our data into three categories,
  1. Alphanumeric
  2. Numeric
  3. Others
byte, char, string datatypes are represents Alphanumeric data. C# also having numeric datatypes. Lets we see what are all datatypes in c# using below diagram,


Below table represents min value and max value of each datatypes and what values it may have,

Category
Datatype
Range
Type of data
Alphanumeric
Byte
28 = 0 – 255
ASCII
Char
216 = 0 – 65535
UNICODE
String
Unlimited
Series of UNICODE
Numeric
Without Decimals
Signed numbers
Short / Int16
216 =  - 32768 to 32767
0 to 9
Int / Int32
232
0 to 9
Long/Int64
264
0 to 9
Unsigned numbers
Ushort/ Uint16
216 = 0 to 65535
0 to 9
Uint/Int32
232
0 to 9
Ulong/Int64
264
0 to 9
With Decimals
Float
Precision up to 7 decimals
0 to 9
Double
Precision up to 16 decimals
0 to 9
Decimal
Precision up to 32 decimals
0 to 9

0 comments:

Post a Comment