- C#.Net is a rich language that is why every variable has a data type in it.
- Data types assign the type of the value stored in a variable.
- There are several data types are present in C#.Net which are used by the programmer at the time of creation of program.
In C#.Net data types are categorized into three parts which are given below:
- Value Type
- Reference Type
- Pointer Type
- Value type data types are those data types which contains the actual data value.
- These data types are of fixed length and stored on the stack of memory.
- These data types are stored the copy of the value.
- They are derived from the System.ValueType Class.
We can further classify the Value Types into two parts
- User-Defined Types
- Pre-Defined Types
User-Defined types are those value types which are defined by the users. There are two types of User-Defined types present in C# given below in the table:
Predefined Types are those value types which are already defined in C#. Following table contains all the Pre-Defined value data types of C#:
- Reference Type data types are those data types which contains the reference of the value.
- These data types are of varied length and stored on the heap in memory.
- These data types do not contain copy of value like Value Type. On the other side these contain address of the value.
We can also classify Reference Type into two categories:
User-Defined Reference Types are those data types which are defined by the users. Following tables contains the User-Defined Reference Type present in C#:
Pre-Defined Reference Types are those data types which are already defined in C#. Following table tells us about the Pre-Defined Reference type present in C#:
- Pointer type data type is only used in the context of unsafe code.
- Pointer Types variables are basically used to store the memory address of variable of any other data type.
- We are giving here the syntax of pointer type data type: