There have been times when there was a need to use the C# keywords as names of the variable, but we were not able to do so as it is not allowed and gives a Compile Time error.
For e.g. the below code, will give you a compile time error stating: "Cannot implicitly convert type 'System.Random' to 'string'"
- Random string = new Random();
Although, there is a way in which we can use this name without any error. Please see the below code:
- Random @string = new Random();
The same thing can be used for other keywords as well.
Please feel free to post your inputs as comments.
Thanks
Vipul


Sonu ChaudharyPosted Feb 25, 2016, 2:15 AM EST
nice article
Vivek BansodPosted Jan 25, 2016, 3:42 AM EST
That's interesting but what could be the scenario where one will use keywords as variable? Just trying to understand purpose of this feature.
Vlad LandcovschiPosted Jan 15, 2016, 4:50 AM EST
Interesting
Dhanik SahniPosted Dec 28, 2015, 9:36 PM EST
interesting
Ricky NguyenPosted Sep 25, 2015, 1:11 AM EDT
Nice ^^
pooja guptaPosted Jul 4, 2015, 10:40 AM EDT
This is interesting. Thanks