Premitives (Data Types) in C#

Posted by in C# category on for Beginner level | Views : 6222 red flag
Rating: 5 out of 5  
 1 vote(s)

Data types that is commonly called as Primitives are predefined in C#. There are several data types in C#.

Primitives are nothing but data types in C# that is used to store specific types of data.

There are eight integer types of primitives.

Type Primitive Description Range
sbyte System.SByte 8 bit -128 to 127
byte System.Byte 8 bit 0 - 255
ushort System.UInt16 16 bit unsigned 0 to 65,535
short System.Int16 16 bit -32,768 to 32,767
int System.Int32 32 bit -2,147,483,648 to 2,147,483,647
uint System.UInt32 32 bit unsigned 0 to 4,294,967,295
long System.Int64 64 bit -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
ulong System.UInt64 64 bit unsigned 0 to 18,446,744,073,709,551,615

There are two floating-point types of primitives.

Type Primitive Description Range
float System.Single 32 bit +/-1.5x10-45 to +/-3.4x10+38 precision of 7 digits
double System.Double 64 bit -1.79769313486232e308 to 1.79769313486232e308

There is one decimal type primitives.

Type Primitive Description Range
decimal System.Decimal 128 bit +/-1.0x10-28 to +/-7.9x10+28 precision of 28-29 digits

There is one boolean type of primitive.

Type Primitive Description Range
bool System.Boolean boolean true, false

and there is two character type of primitives.

Type Primitive Description Range
char System.Char 16 bit Unicode /u0000 - /uffff
string System.String - immutable, specified length

In order to achive better peformance in the application, we should select the data type judiciously considering its range.

Page copy protected against web site content infringement by Copyscape

About the Author

Full Name: Sheo Narayan
Member Level: HonoraryPlatinum
Member Status: Administrator
Member Since: 7/8/2008 6:32:14 PM
Country: India
Regards, Sheo Narayan

Ex-Microsoft MVP, Author, Writer, Mentor & architecting applications since year 2001. Connect me on | |

Login to vote for this post.

Comments or Responses

Login to post response

Comment using Facebook(Author doesn't get notification)