C# Data Types
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 Type | Memory Size | Range |
short | 2 byte | -32,768 to 32,767 |
signed short | 2 byte | -32,768 to 32,767 |
unsigned short | 2 byte | 0 to 32,767 |
char | 1 byte | -128 to 127 |
signed char | 1 byte | -128 to 127 |
unsigned char | 1 byte | 0 to 127 |
int | 2 byte | -32,768 to 32,767 |
signed int | 2 byte | -32,768 to 32,767 |
unsigned int | 2 byte | 0 to 32,767 |
short int | 2 byte | -32,768 to 32,767 |
unsigned short int | 2 byte | -32,768 to 32,767 |
signed short int | 2 byte | 0 to 32,767 |
long int | 4 byte | |
unsigned long int | 4 byte | |
signed long int | 4 byte | |
float | 4 byte | |
double | 8 byte |
2. Reference Data Types: Reference data type contains the reference to the actual data such as object variable.
- Predefined Types: they are predefined types such as strings and objects.
- User defined Types: These are defined by User such as classes and interface.