Tech moves fast! Stay ahead of the curve with Techopedia!
Join nearly 200,000 subscribers who receive actionable tech insights from Techopedia.
An identifier, in C#, is the user-defined name of a program element. It can be a namespace, class, method, variable or interface.
Identifiers are symbols used to uniquely identify a program element in the code. They are also used to refer to types, constants, macros and parameters. An identifier name should indicate the meaning and usage of the element being referred.
C# is a programming language that is compiled and has its implementation such that the identifiers are only compile-time entities. During run time, each identifier will be referred by its reference to the memory address and offset the compiler assigned to its textual identifier token.
Like in C/C++, identifiers in C# are case-sensitive.
Microsoft recommends the use of Camel or Pascal notations, along with semantics, for naming identifiers instead of the Hungarian notation that was used prior to .NET programming. For example, "employeeSalary" might represent Camel notation wherein the first letter of all the words is capitalized except the first word. Camel notation is used to name private members, fields and parameters. "EmployeeSalary" is an identifier in Pascal notation, as all the words in the identifier begin with an upper-case letter. It is usually used for type names and nonprivate members of a type.
The rules to be followed while using an identifier include:
An identifier prefixed with "@" is called a verbatim identifier. Although prefixing "@" allows for the use of keywords, which helps in interfacing with other programming languages, it is not a recommended practice.