It is a placeholder in the memory that can be used to store the data,its value can be changed, using the data type we can specify that what kind of value will be stored in the variable.




string name;
 int age;
 float percentage;

Data type-

It is divided into following two types:

a-value type/simple type/primitive type

b-reference type/complex type/non-primitive type

value-It is used to store the value and can be directly accessed i.e.

Major data types of value type:

a-Numeric i.e. 0-9 or decimal

b-String and Char i-e. 0-9, a-z, special char,but char can store only single char at a time while string can store many chars

c-Boolean-can store only true or false 0 or 1

Numeric-it will store only 0-9, it is furture divided as:

Integer-it will store only whole number

Short integer, long integer, very long integer

Float-it can store decimal as well as float, double

String and Char-it can store anything from a-z, 0-9 or special chars

Sting-can Store number of characters

Char-will store only single char

Boolean-it will accept only true or false or 0 or 1

Literals-A Literal is a type of value that is stored in a variable

Integer Literal -can store only whole number i.e.

Int age=25; //correct 

Int age=25.5;//incorrect

Floating point literal-It can accept decimal i.e

Float age=25; //correct

Float age=25.5; 

String literal-It will accept anything but will be enclosed in the double quotes i.e.


      string name = "Ram";//correct
     string email = "ram@mindstick.com";//correct
     string name = ram;//wrong
     string name='ram'//wrong


 Character Literal-it will accept anything but only single char and will be enclosed in the single quotes i.e.

            char gender = ‘M’;//correct
            char gender = "Male";//incorrect
            char gender = ram;//wrong
            char type='ram'//wrong


Boolean Literal- It will accept only true/false or 0/1 i.e. 

            boolean staus = true;//correct
            boolean status = 0;// correct
            boolean status = ram;//wrong
            char type='ram'//wrong


Identifier- it is name given to variable,constant,function,array


            int salary;//correct
            int = data type;// correct
            salary  = identifier;//wrong



It has the fixed value that cannot be changed during the program execution.We have to initialize the constant while declaring it.

To declare the constant const keyword is used i.e.

  const int age=20;


You can visit these related useful post

Abstraction in c# with example

Threading in C# with Example

Identifiers in c#

Inheritance in C#.Net

Calculator Program in C# .NET

Datagridview Printing in C#

Insert, Delete, Update in DataGridView with DataTable in C#

  Modified On Mar-17-2018 05:01:51 AM

Leave Comment