Introduction
C# is rich in features and keywords which helps to make the language strong and versatile. Keywords are predefined sets of reserved words that have a special meaning that is known to the compiler. These keywords have special significance so that we cannot use them as identifiers for class name, variable name, and interface name. In this blog, you will learn about C# keywords.
C# Keywords List
List of Reserved Keywords is given below table which is available in C# Programming language,
| using | as | finally | sbyte |
| int | is | fixed | sealed |
| char | abstract | foreach | sizeof |
| float | base | goto | typeof |
| double | case | return | stackalloc |
| short | try | implicity | struct |
| long | catch | in | switch |
| string | checked | internal | throw |
| true | class | interface | throw |
| false | const | lock | ulong |
| static | decimal | namespace | unchecked |
| this | enum | new | unsafe |
| byte | default | null | ushort |
| bool | private | object | virtual |
| break | protected | operator | void |
| continue | public | out | volatile |
| if | delegate | override | extern |
| else | do | params | using static |
| while | event | readonly | |
| for | explict | ref |
C# Keywords Categorized with their types or groups
| Namespace Keywords | using, operator, extern alias |
| Type Keywords | string, int, long, bool, byte, char, class, decimal, double, enum, float, sbyte, short, struct, uint, ulong, ushort |
| Operator Keywords | is, await, as, new, sizeof, typeof, checked, unchecked, stackalloc |
| Statement Keywords | if, else, switch, case, do, for, foreach, in, while, break, continue, default, goto, return, yield, throw, try, catch, finally, checked, unchecked, fixed, lock |
| Literal Keywords | null, false, true, value, void |
| Modifier Keywords | public, private, protected, internal, abstract, async, const, event, extern, new, override, partial, readonly, sealed, static, unsafe, virtual, volatile |
| Method Parameter Keyword | params, ref, out |
| Access Keywords | base, this |
| Contextual Keywords | add, var, dynamic, global, set, value |
| Query Keywords | from, where, select, group, into, orderby, join, let, in, on, equals, by, ascending, descending |
Essential C# Keywords
| Concept | Description |
| public | Accessible from any code, anywhere in the project. |
| private | Accessible only within the same class or struct. |
| protected | Accessible within the same class and derived classes. |
| internal | Accessible within the same assembly. |
| protected internal | Accessible within its own assembly or by derived classes. |
| class | Defines a class, a blueprint for creating objects. |
| interface | Declares a contract that classes can implement. |
| struct | Creates a value type holding data directly. |
| enum | Defines an enumeration, a set of named constants. |
| record | Defines an immutable data class. |
| string | Represents text data. |
| int | A 32-bit integer. |
| bool | Represents a Boolean value (true or false). |
| double | A double-precision floating-point number. |
| decimal | Used for high-precision decimal numbers. |
| var | Allows the compiler to infer the type of a variable. |
| static | Belongs to the type itself rather than an instance. |
| virtual | Allows a method to be overridden in a derived class. |
| override | Provides a new implementation of a virtual method. |
| abstract | Must be implemented by derived classes. |
| async | Marks a method as asynchronous. |
| await | Waits for the completion of an asynchronous operation. |
| if, else | Executes code based on a conditional expression. |
| switch | Allows multiple branches of execution. |
| for, foreach | Used for iterating over collections or repeating code. |
| while, do | Executes a block of code repeatedly. |
| break | Exits a loop or a switch statement. |
| continue | Skips the rest of the current loop iteration. |
| return | Exits a method and optionally returns a value. |
| throw | Throws an exception. |
| try, catch, finally | Surrounds code that might throw an exception. |
| null | Represents the absence of a value. |
| default | Provides the default value of a type. |
| using | Ensures that resources are properly disposed of. |
| is | Checks if an object is of a specific type. |
| as | Safely converts an object to a specific type. |
| new() | Instantiates a new object. |
| nameof | Retrieves the name of a variable or type as a string. |
| when | Adds a condition to pattern matching. |
| fixed | Pins a pointer in memory to prevent garbage collection from moving it. |
| unsafe | Allows code that uses pointers. |
| stackalloc | Allocates memory on the stack. |
| volatile | Indicates that a field may be modified by multiple threads. |
| value | Refers to the value being assigned in a property setter. |
| get | Defines a property accessor that retrieves the value. |
| set | Defines a property mutator that sets the value. |
| yield | Used in iterator methods to provide a value to the enumerator object. |
| partial | Allows a class or method to be defined in multiple files. |
| where | Specifies constraints on generic type parameters. |
Summary
We cannot use C# standard keywords as identifiers for class names, variable names, and interface names. If you want to learn more about C# keywords, you can refer Essential C# Keywords
If you have any query/suggestion on C# keywords, please leave your thoughts in the comment section below.
Thanks for reading and I hope you like it.

Join the conversation! Your thoughts help the community grow.