Export (0) Print
Collapse All

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

add

Defines a custom event accessor that is invoked when client code subscribes to the event.

async

Indicates that the modified method, lambda expression, or anonymous method is asynchronous.

await

Suspends an async method until an awaited task is completed.

dynamic

Defines a reference type that enables operations in which it occurs to bypass compile-time type checking.

get

Defines an accessor method for a property or an indexer.

global

Specifies the default global namespace, which is otherwise unnamed.

partial

Defines partial classes, structs, and interfaces throughout the same compilation unit.

remove

Defines a custom event accessor that is invoked when client code unsubscribes from the event.

set

Defines an accessor method for a property or an indexer.

value

Used to set accessors and to add or remove event handlers.

var

Enables the type of a variable declared at method scope to be determined by the compiler.

where

Adds constraints to a generic declaration. (See also where).

yield

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).

Reference

Concepts

Other Resources

Show:
© 2014 Microsoft