
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
What are reserved keywords in C#?
Keywords are reserved words predefined to the C# compiler. These keywords cannot be used as identifiers. If you want to use these keywords as identifiers, you may prefix the keyword with the @ character.
In C#, some identifiers have special meaning in the context of code, such as get and set are called contextual keywords.
The following table lists the reserved keywords −
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 |
Let us see an example of using bool reserved keyword in C# −
Example
using System; using System.Collections; class Demo { static void Main() { bool[] arr = new bool[5]; arr[0] = true; arr[1] = true; arr[2] = false; arr[3] = false; BitArray bArr = new BitArray(arr); foreach (bool b in bArr) { Console.WriteLine(b); } bool str = arr[1]; Console.WriteLine("Value of 2nd element:"+str); } }
Output
True True False False False Value of 2nd element:True
- Related Articles
- What are Reserved Keywords in Python?
- Reserved keywords in C++?
- What is the difference between keywords and reserved words in Java?
- What are contextual keywords in C#?
- What are signed and unsigned keywords in C++?
- What are Reserved Words in JavaScript?
- What are Reserved Words in Python?
- What are the different types of keywords in C language?
- How many keywords are there in C++?
- What Are LSI Keywords in Digital Marketing?
- Keywords in C#
- What Are Keywords Shortcuts for Youtube?
- C++ Keywords
- Important Keywords in C#
- What are the different types of keywords in Java?

Advertisements