Friday 10 February 2012

C# Data types

In C#.net language there are 4 types of data types and 2 of which are common because of their using in programming. These 2 commonly used data types are int and float. Now, int types are categorized into two forms these are signed and unsigned. Signed data types are those data types which can store negative value as well as positive value, but Unsigned data types can store only positive values.
The values range of the different data types as follows.

Types AliasAllowed Values
sbyteSystem.SByte-128 to 127
byteSystem.Byte0 to 255
shortSystem.Int16-32,768 to 32,767
ushortSystem.UInt160 to 65,535
intSystem.Int32-2,147,483,648 to 2,147,483,648
uintSystem.UInt320 to 4,294,967,295
longSystem.Int64-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
ulongSystem.UInt640 to 18,446,744,073,709,551,615

Here in the table s stands for signed data types and u stands for unsigned data types.

Now, we also need to store floating point values, for that we need float data types. There are basically three types of floating point data types and these are: float, double and decimal. Here the values range table of floating point data types:

TypesAlias For App. max range App. min range
floatSystem.Single1.5 x 10-45 3.4 x 1038
doubleSystem.Double 5.0 x 10-324 1.7 x 10308
decimalSystem.Decimal1.0 x 10-287.9 x 1028

  
Here three other simple types are available. These are:
              
TypesAlias forAllowed Values
charSystem.Char0 to 65,535
boolSystem.Booleantakes only true or false
stringSystem.Stringtakes only number or sequence
 of characters like "Microsoft"


C# data types are similar to Java but with little difference. 

No comments:

Post a Comment