Unger Technologies LLC

GREG UNGER MY FACEBOOK ATHLETE PAGE MY YOUTUBE CHANNEL Follow me on Twitter FOLLOW ME ON TWITTER

Contextual keywords

A contextual keyword is used to provide a specific meaning in the code, but it is not a reserved word in C#. Some keywords are contextual, meaning they can also be used as identifiers—without an @ symbol.

These are:

KeywordDescription
addDefines a custom event accessor that is invoked when client code subscribes to the event.
asyncIndicates that the modified method, lambda expression, or anonymous method is asynchronous.
awaitSuspends an async method until an awaited task is completed.
dynamicDefines a reference type that enables operations in which it occurs to bypass compile-time type checking.
getDefines an accessor method for a property or an indexer.
globalSpecifies the default global namespace, which is otherwise unnamed.
partialDefines partial classes, structs, and interfaces throughout the same compilation unit.
removeDefines a custom event accessor that is invoked when client code unsubscribes from the event.
setDefines an accessor method for a property or an indexer.
valueUsed to set accessors and to add or remove event handlers.
varEnables the type of a variable declared at method scope to be determined by the compiler.
whereAdds constraints to a generic declaration. (See also where).
yieldUsed in an iterator block to return a value to the enumerator object or to signal the end of iteration.

With contextual keywords, ambiguity cannot arise within the context in which they are used.

No comments:

Post a Comment