C# Keywords

Review keywords from the C# language. Each keyword has a link to an example and a description.
Keywords. The glacier is a harsh place for living creatures. The polar bear seeks refuge in a cave. A visitor to this icy world must find a way to survive.
Keyword list. Like a fire brings warmth to this winter place, a keyword brings meaning to a program. We use keywords to control the program's logic.abstractasascendingasyncawaitbaseboolbreakbytecasecatchcharcheckedclassconstcontinuedecimaldefaultdelegatedescendingdodoubledynamicelseenumequalseventexplicitexternfalsefinallyfixedfloatforforeachfromgetgotogroupifimplicitinintinterfaceinternalisjoinletlocklongnameofnamespacenewnullobjectoperatororderbyoutoverrideparamspartialprivateprotectedpublicreadonlyrefreturnsbytesealedselectsetshortsizeofstackallocstaticstringstructswitchthisthrowtruetrytypeofuintulonguncheckedunsafeushortusingvaluevarvirtualvoidvolatilewhenwherewhileyield
Syntax hints. A question mark can mean a ternary statement, or a nullable type. A period can mean a member access or a floating-point number.[A] (Attribute)// ... (Comment)/* ... */ (Comment)~C (Destructor)# (Directive)_ (Discard name){0} (Format)<T> (Generic){[0] = 1} (Indexer initializer): (Inheritance)=> (Lambda)% (Modulo)? (Nullable)?? (Null coalescing)?. (Null conditional)D (Numeric suffix)$"{x}" (String interpolation)? (Ternary)* (Unsafe)(1, "x") (ValueTuple)@ (Verbatim literal)
Reserved versus contextual. Here is an important part of the syntax of C#. Some terms, like "for," are reserved keywords—we cannot name a variable "int for."
Reserved, continued. Other terms, like "where," are contextual keywords. They have a special meaning in a certain place (like a query expression) but we can name a variable "where."
A final note. For survival in the arctic world, tiny syntax details are less important. The big picture is what matters. Know first the important things like string and int.
© 2007-2020 Sam Allen. Every person is special and unique. Send bug reports to
Dot Net Perls