C# Fundamentals in Hindi


1.  Identifiers:

 

An identifier is a user-define name given to an entity and used to identify a class, interface, variable, methods, member, or namespace.

i.e. - Every human has a name as its own identity.

 

Rules for defining Identifiers:

      i.            The only allowed characters for identifiers- ([A-Z][a-z][0-9]), ‘_‘(underscore). For example “geek@” is not a valid C# identifier as it contain ‘@’ – special character.

 

   ii.            Identifiers should not start with digits ([0-9]). For example “123geeks” is not valid in the C# identifier.

 

iii.            Identifiers should not contain white spaces.

 iv.             Identifiers are case-sensitive.

    v.            Identifiers cannot contain more than 512 characters.

 

 

 

2. Variables:

A variable is a name of memory location. It is used to store data. Its value can be changed and it can be reused many times.

Here x and y are variables and int is a data type.

 

Rules for defining variables:

àVariable names can contain the letters ‘a-z’ or ’A-Z’ or digits 0-9 as well as the character ‘_’ underscore.

i.e. string name= _Tech123 --allowed

àA variable name can start with alphabet and underscore only. It can't start with digit.

i.e. 123Tech --not allowed

 

àNo white space is allowed within variable name.

i.e. tech 123  --not allowed

 

àA variable name must not be any reserved word or keyword i.e. if, else, int, long, string, class etc.

 

 

 

Valid Variables Names

int age;

string _name;

string Address123;

 

Invalid Variables Names

int if; // "if" is a keyword

string 20name; // Cannot start with digit

 

Initializing Variables

int x; // Declaring variable x.

x = 5; // initializing x with value 5.

 

int y = 10; // Declaring and initializing the variable at same time.

y=25; // Reuse value of y variable.

 

 

Identifier

 

Variable

Identifier is used to name a variable, function, class, structure etc.

Variable is used to name a memory location, which holds a value.

Created to give a unique name to an entity.

Allots a unique name to a particular memory location.

All identifiers are not variable.

All variables names are identifier.

 

 

 

 

3. Literals:

Literal is a value that is used by the variables. Fixed or constant values are literals. Values can be either an integer, float or string, etc.

 

 

In the above image 100 is a literal or constant.

 

 

Examples:

 

Int id    = 100;                --Integer literal.

 

String name =”Tech”;    --String literal.

 

Char age=’20’;                  --Characters literal.

 

Bool isActive = true;       --Boolean literal.

Comments

Popular posts from this blog

.NET Framework Introducton

CLR with advantages and architectures

Definition and features of C#.