In C#, keywords are reserved words that have a specific meaning and functionality in the language. They cannot be used as identifiers (such as variable names, method names, or class names) in your code.
C# Keyword List:
Here is a list of C# keywords as of the latest version (C# 9):
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 int interface internal is lock long namespace |
new null object operator out 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 |
Here are some common categories of C# keywords:
1. Access modifiers:
These keywords determine the accessibility of classes, methods, properties, and fields. Examples include public, private, protected, and internal.
2. Control flow statements:
These keywords are used to control the execution of code based on certain conditions. Examples include if, else, while, do, for, switch, break, continue, and return.
3. Object-oriented programming keywords:
C# is an object-oriented language, and it has keywords that are used to define classes, methods, and properties. Examples include class, interface, abstract, sealed, new, override, and virtual.
4. Data type keywords:
C# supports several built-in data types, such as int, float, double, bool, char, string, and object.
5. Exception handling keywords:
These keywords are used to handle runtime errors and exceptions. Examples include try, catch, finally, and throw.
6. Miscellaneous keywords:
C# has several other keywords that serve various purposes, such as namespace, using, const, readonly, static, unsafe, and volatile.