Datatype specifies the type of data which variable can hold. For strongly typed programming languages such as C Sharp, you need to specify the datatype at the time of declaring a variable. In C sharp, datatypes are divided into three.
- Value data type
- Reference data type
- Pointer data type
Value data type
The value data type includes char, int, float, boolean etc. A value can be assigned to these types of variables directly. The value data type is further divided as:
- Pre-defined data types and
- User-defined data types.
|char||1 byte||-128 to 127|
|unsigned char||1 byte||0 to127|
|short||2 byte||-32,768 to 32,767|
|unsigned short||2 byte||0 to 65,535|
|int||4 byte||-2,147,483,648 to -2,147,483,647|
|unsigned int||4 byte||0 to 4,294,967,295|
|long||8 byte||9,223,372,036,854,775,808 to 9,223,372,036,854,775,807|
|unsigned long||8 byte||0 – 18,446,744,073,709,551,615|
Reference data type
The reference data type does not contain the actual data, but instead, it holds references to the variables.
Pointer data types
A pointer is declared in C sharp using asterisk symbol (*). they hold the memory location of other variables.