C# keywords are reserved words in the C# programming language that have predefined meanings and cannot be used as identifiers (names) for variables, classes, methods, or other elements in the code. These keywords are an essential part of the language syntax and are used to define various programming constructs, control flow, data types, access levels, and more.
Category | Keywords | Description |
---|---|---|
Modifier Keywords | abstract , sealed , static , partial , virtual , override , async , new , readonly , volatile , unsafe |
Keywords used to modify the behavior of classes, methods, and members in the C# code. |
Access Modifier Keywords | public , private , protected , internal , protected internal |
Keywords used to control the visibility and accessibility of classes, methods, and members in C# code. |
Statement Keywords | if , else , switch , case , default , while , for , do , break , continue , return , try , catch , finally , throw |
Keywords used to define control flow, loops, exception handling, and branching statements in C# code. |
Method Parameter Keywords | ref , out , params , in |
Keywords used to define method parameters with specific behaviors, such as passing by reference or variable-length parameters. |
Namespace Keywords | namespace , using , alias |
Keywords used to define and manage namespaces and simplify type references in C# code. |
Operator Keywords | is , as , sizeof , typeof , stackalloc |
Keywords used to perform various operations and checks, such as type checking and memory allocation. |
Access Keywords | base , this |
Keywords used to access members in the base class or the current instance of the class, respectively. |
Literal Keywords | true , false , null , default |
Keywords used to represent literal values of boolean, null, and default values in C# code. |
Type Keywords | class , interface , struct , enum |
Keywords used to define different types and their structures in C# code. |
Contextual Keywords | var , dynamic , nameof , global , value , when , yield , join , into |
Keywords with contextual meanings depending on their usage, such as var for implicit typing. |
Query Keywords | from , where , select , group , into , orderby , join , let , on , equals , by , ascending , descending |
Keywords used in LINQ query expressions for data querying and manipulation in C# code. |