Contextual Keywords

A language with too many reserved keywords can definitely be annoying to developers because of the need to escape keywords all over the place. Especially because keywords are usually based on the English language, clashes with identifiers are a very real risk. Imagine what would happen if value were a reserved keyword:

int @value = discount.Value;

As a matter of fact, value has a reserved meaning in C#, but only in certain contexts. This combines the best of both worlds, using natural-sounding English words to represent programming language features while leaving the word available for use as an identifier in certain contexts. You can refer to those identifiers with occasional special meaning as contextual keywords, although ...

Get C# 5.0 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.