Mike-Ward.Net

Using Keywords as Identifiers in C#

There are times when keywords and identifiers collide when coding. This is particularly true in code generators but sometimes the keyword really describes the purpose of the identifier (like default or ref for instance). You can come up with clever naming schemes but there is a simpler way. In C#, you can just prefix the identifier with an @ symbol.

Keywords are predefined reserved identifiers that have special meanings to the compiler. They cannot be used as identifiers in your program unless they include @ as a prefix. For example, @if is a legal identifier but if is not because it is a keyword. The C# Language

← newer older →
.Net, Technology, Life, Whatever

Recent Posts

VSColorOutput for VS 2017 Released
Quick ReSharper tip for inline templates
NoSQL vs. NewSQL: What's the Difference?
Exploring Mithril, A JavaScript Framework for Building Brilliant Applications
Tweetz 1.1
Tweetz Desktop 1.0
Tweetz 0.11 Released
More... (1073)

Donate with PayPal