What is a keywords in c#

C# Keywords

C# contains reserved words, that have special meaning for the compiler. These reserved words are called "keywords". Keywords cannot be used as a name (identifier) of a variable, class, interface, etc.
Keywords in C# are distributed under the following categories:

Modifier Keywords

Modifier keywords are certain keywords that indicate who can modify types and type members. Modifiers allow or prevent certain parts of programs from being modified by other parts.

                   Modifier Keywords

Access Modifier Keywords:
Access modifiers are applied on the declaration of the class, method, properties, fields and other members. They define the accessibility of the class and its members.

Access ModifiersUsage
publicThe Public modifier allows any part of the program in the same assembly or another assembly to access the type and its members.
privateThe Private modifier restricts other parts of the program from accessing the type and its members. Only code in the same class or struct can access it.
internalThe Internal modifier allows other program code in the same assembly to access the type or its members. This is default access modifiers if no modifier is specified.
protectedThe Protected modifier allows codes in the same class or a class that derives from that class to access the type or its members.

Statement Keywords

Statement keywords are related to program flow.

forfor reachinwhilebreak

Method Parameter Keywords

These keywords are applied on the parameters of a method.
For Example:-
params, ref

Namespace Keywords

These keywords are applied with namespace and related operators.

using. operator:: operatorextern alias

Operator Keywords
Operator keywords perform miscellaneous actions.

as issizeofnewtypeofstackallocchecked, unchecked
Access Keywords
Access keywords are used to access the containing class or the base class of an object or class.

For Example:- Base, This

Literal Keywords
Literal keywords apply to the current instance or value of an object.


Type Keywords

Type keywords are used for data types.

sbyteshortstringstructuint, ulong, ushort
Contextual Keywords
Contextual keywords are considered as keywords, only if used in certain contexts. They are not reserved and so can be used as names or identifiers.

addvardynamicglobalset, value

Post a Comment