Identifiers in c#

Identifiers are tokens or symbols which are uniquely identify the element. They are names of things like variables or fields. Identifiers are names given to namespaces, classes, methods, variables, and interfaces etc. Identifiers in c# are case sensitive. For example abc is not equal to ABC. Identifiers can be combination of letters, numbers, and underscores. Keywords are not defined as identifiers. It can make the identifiers by using Unicode character as “@”.

For example

int @int=10;


Valid identifiers in C# are following this rule

·         An identifier must start with a letter or an underscore.

·         After the first character, it may contain numbers, letters, connectors, etc.

·          If the identifier is a keyword, it must be prep ended with “@” .

For Example:

The following names are valid identifiers in C#:

1.       WORLD

2.       world

3.       w_orld

4.       HelloWorld

5.       Z

6.       Z

7.       \u098world

8.       @public

9.       _world

And some invalid identifiers

1.       2world  //error because first letter is number

2.       Public  //error because it is keyword

3.       \u0027format // error because Unicode formatting character

  1. Well, C has a certain limitation in its character. When 32 character exceeds, it will be ignored by the compiler.

Leave Comment