#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 .NET technologies. Equally passionate about my own personal projects related to family history and preservation of family stories and photos.

One Response 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.

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 )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 43 other followers