#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";
Advertisements

About Sean
Software developer in the Twin Cities area, passionate about .NET technologies. Equally passionate about my own personal projects related to family history and preservation of family stories and photos.

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 Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: