Home > DeveloperSection > Interviews > What is dataType and Variable?

Posted on    September-19-2016 6:49 AM

 C# C#  Variable 
 1 Answer(s)
  51  View(s)
Rate this:

Abhishek Srivasatava
Abhishek Srivasatava

Total Post:54

Posted on    September-19-2016 6:49 AM


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

Value type

In this type we can directly assign the data to the variable.

Below are the some of the example of value type :

Integer :

It is further divided  into signed and unsigned datatype

Signed datatype are those datatype whose value can be negative.

example :

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

Floating type

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.

Modified On Sep-19-2016 07:10:09 AM

Don't want to miss updates? Please click the below button!

Follow MindStick