C# Data Types

Facebooktwitterredditpinterestlinkedinmailby feather

A Data type is the type of data which the variable can store such as integer, float, double,
character, etc.
In C#, Data types are divided into three parts
1. Value data type

2. Pointer data type
3. Reference data type

1. Value data type:
1. Primitive data type: They are predefined types store values as Integer, Floating
point, Boolean, Characters, etc.
2. User Defined Types: They are defined by user according to the need of the program
and data management. Such as structure and enumerations.
The size of the data type depends upon the architecture of the Operating System. Let’s see
the size of the data types according to 32 bit Operating System .

Data TypeMemory SizeRange
short2 byte-32,768 to 32,767
signed short2 byte-32,768 to 32,767
unsigned short2 byte0 to 32,767
char1 byte-128 to 127
signed char1 byte-128 to 127
unsigned char1 byte0 to 127
int2 byte-32,768 to 32,767
signed int2 byte-32,768 to 32,767
unsigned int2 byte0 to 32,767
short int2 byte-32,768 to 32,767
unsigned short int2 byte-32,768 to 32,767
signed short int2 byte0 to 32,767
long int4 byte
unsigned long int4 byte
signed long int4 byte
float4 byte
double8 byte

2. Reference Data Types:

Reference data type contains the reference to the actual data such as object variable.

  1. Predefined Types: they are predefined types such as strings and objects.
  2. User defined Types: These are defined by User such as classes and interface.

3. Pointer Data Type:

Pointer is a data type which is used to store the address or location of any variable. In 32 bit architecture, pointer is of 2 byte. In a 64 bit architecture, pointer is of 4 byte.

eg. int *a; //pointer to a integer

Facebooktwitterredditpinterestlinkedinmailby feather

Leave a Comment