TOP CENTER
     

10

What are Identifiers?   New Page 1
What is Object-Oriented Programming?
What is Microsoft .NET?
What is C#?
What is Common Language Runtime (CLR)?
What do you mean by .NET Framework Class Libraries?
What are Namespaces?
What are the requirements for developing a C# application?
What are the steps involved in developing a C# application?
What will happen after the compilation of a C# program?
What are Identifiers?
What are Keywords?
How do I begin programming with C#?
What are the different editors that are available for C# programming?
How do I build a C# application using Command Line Compiler?
How do I build a C# application using Visual Studio .NET 2003?
How do I build a C# application using Visual Studio .NET "Whidbey"?
 

Anand Narayanaswamy

Posted - February 05, 2005
 
Identifiers are the names given to classes, methods, variables and interfaces. It must be a whole word and starts with either an alphabet or an underscore. They are case sensitive. The main point you should bear in mind is that the names should not clash with C# keywords.

Some programmers use @ prefix as a first character while declaring identifiers to avoid clash with a keyword but it is not a recommended practice. Following names are valid identifiers in C#

1. Hello
2. hello
3. H_ello
4. HelloWorld

You should name the variables using the standard DataType prefixes. Also the first alphabet after the prefix should be capitalized. Table 10.1 shows a list of prefixes for the various .NET DataTypes. You will learn more about DataTypes in a later FAQ.

Interfaces should be named with "I" as the first alphabet so that you can easily distinguish it from a class.

All Windows Forms controls should be named with the special prefixes as shown in Table 10.2. This is to avoid confusion and also to distinguish between other controls in a complex project. As explained above, the first alphabet after the prefix should be capitalized. Once you master the naming conventions and prefixes it would be very easy for you to write and maintain code.

It is beyond the scope of this chapter to cover the prefixes of all the .NET controls. You will find a detailed list of them on the MSDN Library.