Export (0) Print
Expand 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.

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

Community Additions

ADD
Show:
© 2014 Microsoft