Keywords in C#: Types of Keywords with Examples

Learn what keywords are in C#, the different categories of keywords, and see practical examples of how each type is used in real code.

What are Keywords?

Keywords are reserved words in C# that have special meaning to the compiler and cannot be used as identifiers, such as variable or method names, because the language relies on them to define its structure and behavior.

Value Type Keywords

Keywords like int, float, double, char, bool, and decimal define value type variables, each representing a specific kind of data with a fixed size and range.

Modifier Keywords

Access modifiers such as public, private, protected, and internal control the visibility of classes, methods, and variables, while modifiers like static, sealed, and abstract define how members behave.

Control Flow Keywords

Keywords such as if, else, switch, for, while, foreach, break, and continue direct the flow of execution in a program, allowing you to build logic that responds to different conditions.

Contextual Keywords

Some keywords, like var, async, await, and yield, are contextual, meaning they only carry special meaning in specific contexts and can otherwise be used as regular identifiers elsewhere in the code.

Conclusion: Understanding the different categories of C# keywords helps you read and write code more fluently, since these reserved words form the essential vocabulary of the entire language.

Ready to Master C# Programming Course?

Join Uncodemy's hands-on training program with expert mentors and real-world projects.