What are identifiers in C#?


An identifier is a name used to identify a class, variable, function, or any other user-defined item. The basic rules for naming classes in C# are as follows −

  • A name must begin with a letter that could be followed by a sequence of letters, digits (0 - 9) or underscore. The first character in an identifier cannot be a digit.

  • It must not contain any embedded space or symbol such as? - + ! @ # % ^ & * ( ) [ ] { } . ; : " ' / and \. However, an underscore ( _ ) can be used.

  • It should not be a C# keyword.

The following are some examples of identifiers −

Class Names

class Calculation
class Demo

Valid Functions Names

void display()
void getMarks()

Variable Names

int a;
int marks;
int rank;
double res_marks;

Updated on: 20-Jun-2020

729 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements