There are some reserved keywords in C# which can not be used as names for variables ,class and methods so we can say these Keywords are predefined, reserved identifiers that have special meanings to the compiler. They cannot be used as identifiers. But we can use these keywords as identifier with prefix @ . suppose @abstract can be used but only abstract cannot be used because this is a keyword.
Following is the list of reserved words or keywords in C#:
abstract | as | base | bool |
break | byte | case | catch |
char | checked | class | const |
continue | decimal | default | delegate |
do | double | else | enum |
event | explicit | extern | false |
finally | fixed | float | for |
foreach | goto | if | implicit |
in | in (generic modifier) | int | interface |
internal | is | lock | long |
namespace | new | null | object |
operator | out | out (generic modifier) | override |
params | private | protected | public |
readonly | ref | return | sbyte |
sealed | short | sizeof | stackalloc |
static | string | struct | switch |
this | throw | true | try |
typeof | uint | ulong | unchecked |
unsafe | ushort | using | virtual |
void | volatile | while |
Note:
C# defines a set of words that have unique meaning when they are used in certain situation, these are called contextual keywords. These are as follows
Get
Set
Yield
Where
partial