#18 – What Is an Identifier?

An identifier is any name that you choose to use in a C# program for things like: variables, classes, interfaces, methods, properties, etc.

The rules for naming identifiers include:

  • They are case sensitive  (i.e. “name” is different from “Name”)
  • They must begin with a letter or underscore (‘_’)
  • They cannot include spaces
  • They can include Unicode characters
  • They cannot match any of the built-in C# keywords

You can actually name an identifier with a name matching a built-in keyword if you prefix the identifer with the ‘@’ symbol.  In the following example, we declare a variable of type string and name the variable “string”.  This is legal in C#, but not a good practice.

string @string = "Don't do this";

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

6 Responses to #18 – What Is an Identifier?

  1. Jorge Luis says:

    Hey, the @ thing is a nice trick, I didn’t know it.

    Great site by the way, keep up the good work.

  2. Parveen Arora says:

    Awesome @.

  3. Pingback: #981 – Full List of C# Keywords | 2,000 Things You Should Know About C#

  4. voxstudios says:

    Unicode characters is a nice little fun fact!

    int Δ = a – b;

Leave a comment