C# Identifiers (original) (raw)
Last Updated : 11 Jan, 2025
In programming languages, identifiers are used for identification purposes. Or in other words, identifiers are the user-defined name of the program components. In C#, an identifier can be a class name, method name, variable name, or label.
**Example:
public class GFG {
static public void Main ()
{
int x;
}
}
Here the total number of identifiers present in the above example is 3 and the names of these identifiers are:
- **GFG: Name of the class
- **Main: Method name
- **x: Variable name
Rules for Defining Identifiers
There are certain valid rules for defining a valid C# identifier. These rules should be followed, otherwise, we will get a compile-time error.
**Example:
C# `
// Simple C# program to illustrate identifiers using System;
class Geeks { // Main Method static public void Main() { // variable int a = 10; int b = 39; int c;
// basic operation
c = a + b;
Console.WriteLine("The sum of two number is: {0}", c);
}
}
`
Output
The sum of two number is: 49
Below data shows the identifiers and keywords present in the above example:
- **Keywords: using, public, static, void, int.
- **Identifiers: Geeks, Main , a, b, c.