Array Class Collections File String .NET Algorithm ASP.NET Cast Compression Data Delegate Directive Enum Exception If Interface Keyword LINQ Loop Method Number Regex Sort StringBuilder Struct Switch Time Value Windows WPF
A language has grammar. It has syntax. It has words. A programming language too has words: these are keywords. Along with syntax, we use keywords to create meaning. And in this way we create programs that do useful things.
Each keyword is listed in alphabetical order in the following section. These are only the reserved keywords. The list was taken from the C# Programming Language Specification third edition.abstractasbaseboolbreakbytecasecatchcharcheckedclassconstcontinuedecimaldefaultdelegatedodoubleelseenumeventexplicitexternfalsefinallyfixedfloatforforeachgotoifimplicitinintinterfaceinternalislocklongnamespacenewnullobjectoperatoroutoverrideparamsprivateprotectedpublicreadonlyrefreturnsbytesealedshortsizeofstackallocstaticstringstructswitchthisthrowtruetrytypeofuintulonguncheckedunsafeushortusingvirtualvoidvolatilewhile
Note:Reserved keywords cannot be used as variable identifiers or member names in the C# language.
And:They are part of the language grammar that is used to parse programs. They are at the core of the C# language.
Some keywords are only considered keywords when used in certain contexts. These contexts include query expressions. Contextual keywords are still usable as identifiers, unlike reserved keywords.Contextual
Programs become fantastically complex creatures after enough features are added. The principle of information hiding allows you to prevent certain parts of a program from accessing other parts.
Tip:In the C# language, information hiding is introduced with accessibility keywords and domains.
Accessibility is specified with an accessibility modifier on each class member. These keywords can be used with static members as well. The default, and usually the best, accessibility of a member is private.publicprotectedinternalprotected internalprivate
Review:Information hiding can make a program of unmanageable complexity manageable. It introduces synthetic barriers.
And:This greatly reduces the possibility of spaghetti code and needlessly involved logic between discrete parts.Spaghetti Code
Programs are not compiled in a single step. They are first converted into tokens. We explore the concept of tokens in the C# programming language. Tokens are understood at the lexical level.
However:It is possible to be a proficient C# developer without knowing exactly how the language uses tokens.Token
Many languages have keywords in common. This is why many programmers find the first language they learn is the hardest. You can use a for-loop in C++ the same as in C# or Java. Some keywords (like unsafe) are language-specific.
And:Programming languages have quirks.
An if-statement in C# has slight differences to one in C++.
This keeps things interesting.
Most languages use fixed character strings such as for, do, and if, as punctuation marks or to identify constructs. Such character strings are called keywords. Aho et al., p. 79
Keywords are essential to understanding the C# language. On the surface, they seem to be the entire language. But the intricate interactions between them and lower-level parts of the .NET Framework represent a greater part.