Contextual Keywords (C# Reference)
A contextual keyword is used to provide a specific meaning in the code, but it is not a reserved word in C#. The following contextual keywords are introduced in this section:
Keyword |
Description |
---|---|
Defines a custom event accessor that is invoked when client code subscribes to the event. |
|
Indicates that the modified method, lambda expression, or anonymous method is asynchronous. |
|
Suspends an async method until an awaited task is completed. |
|
Defines a reference type that enables operations in which it occurs to bypass compile-time type checking. |
|
Defines an accessor method for a property or an indexer. |
|
Specifies the default global namespace, which is otherwise unnamed. |
|
Defines partial classes, structs, and interfaces throughout the same compilation unit. |
|
Defines a custom event accessor that is invoked when client code unsubscribes from the event. |
|
Defines an accessor method for a property or an indexer. |
|
Used to set accessors and to add or remove event handlers. |
|
Enables the type of a variable declared at method scope to be determined by the compiler. |
|
Adds constraints to a generic declaration. (See also where). |
|
Used in an iterator block to return a value to the enumerator object or to signal the end of iteration. |
All query keywords introduced in C# 3.0 are also contextual. For more information, see Query Keywords (C# Reference).