You can use reserved identifiers as variable names in C Sharp

December 8th, 2017 | #csharp

TIL you can use reserved identifiers in C# if you use @ as a prefix.

According to the C# docs:

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, @int is a valid identifier, but int is not because int is a keyword.

The identifier—without the @ as prefix—can be seen as a normal identifier in other languages, because the character @ is actually not part of the identifier.

This can be useful when you are interfacing with other programming languages. 🧐

© 2018 Tonny Garić | With from Nijmegen, The Netherlands