In c#, Keywords are the predefined set of reserved words that have special meaning for the compiler. So the keywords in c# cannot be used as identifiers such as variable name, class name, etc., in our applications.
In c#, if you want to use Keywords as variable names (identifiers), you need to include
@ as a prefix for your variable names. For example, @switch is a valid identifier, but the switch is not because it’s a keyword and having a special meaning for the compiler.
Following is the example of using the reserved keywords as variable names by including
@ as a prefix in c# programming language.
public class @class
public int age;
static void Main(string args)
@class p1 = new @class();
p1.age = 10;
Console.WriteLine("Press Enter Key to Exit..");
If you observe the above c# example, we used a class keyword as a variable name (@class) by including
@ as a prefix.
When you execute the above program, you will get the result as shown below.
We can use keywords as variable names in c# programming language based on our requirements.
In c#, Keywords are differentiated as two types, those are
The following table lists the available reserved keywords in the c# programming language.
|virtual||typeof||uint||ulong||out (generic modifier)|
In c#, Contextual keywords can be used as an identifier in a limited program context, which can be outside of the context.
Generally, whenever the new keywords are added to the C# language, those are treated as Contextual keywords to avoid breaking c# programs that we wrote in older versions.
The following table lists the available Contextual Keywords in c# programming language.
These are the keywords available in c# programming language, and we can use them in our applications based on our requirements.