Contextual Keywords in C#

If we need to use an identifier that has the same name of the keyword in C#, you can do so by prefixing the identifier with the @symbol.

An example for this can be string where i can have an have the implementation similar to the one shown below

string @string =”senthil”;

Even without the @ symbol, some keywords can be used an identifiers directly. Some of these keywords include

  • add
  • dynamic
  • partial
  • where
  • async
  • from
  • select
  • remove
  • global
  • var

The above contextual keywords are only a partial list. There are few more contextual keywords in C# as well.

For example, below is a valid identifier in C#.

int dynamic = 2;

The contextual keywords are valid based on the context in which it is used.

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

This C# program calculates and displays an upper triangular matrix based on user input. Problem Statement: The program takes the...
This C# program serves as a demonstration of bitwise operators, which are fundamental operators used for manipulating individual bits in...
This C# program is designed to interchange or swap the columns of a matrix. A matrix is a two-dimensional array...