DataType is the classification to identify the variable type like int , char, float , string etc.
In C# datatype are classified into three types
* Value types
* Reference types
* Pointer types
In this type we can directly assign the data to the variable.
Below are the some of the example of value type :
It is further divided into signed and unsigned datatype
Signed datatype are those datatype whose value can be negative.
int : 32-bit signed integer type
long : 64-bit signed integer type
short : 16-bit signed integer type
sbyte : 8-bit signed integer type
Unsigned datatype are those datatype whose value can't be negative.
ushort : 16-bit unsigned integer type
ulong : 64-bit unsigned integer type
uint : 32-bit unsigned integer type
Byte : 8-bit unsigned integer
syntax // int a=5;
It is used to accept the input in text format
char 16-bit Unicode character
In this datatype , we can assign the decimal value to the variable.
Reference type :
In reference type , we provide the reference for the data stored in the variable.
The Object is the keyword which is used to store the value in object type, we assigned any type of value like int , char , user defined etc.
Conversion of value type to object type is called Boxing.
Conversion of Object type to Value type is called UnBoxing.
Variable is the stored location of the data in the memory. It is used to retrieve or store temporary data while executing the program.
Declaration for the variable
//<Datatype> <Variable name >
How to define Variable Globally in C#?
In c#, we can define variable globally by using Static concept.
By using Static Keyword before the variable declaration , single memory will be allotted in the program. Irrespective of the number of objects is created for the class.