Thursday, June 24, 2010

Verbatim Identifiers in C#

Not that many people realize that in C#, one can use language keyword names like "void" and "bool" for their identifiers.
The trick is, you need to prefix the name i.e.:

 void @void() {}

declares method named "void".

Of course you would rarely use this feature, if ever but many people start arguing "Why Microsoft did this to begin with?"

I am personally 100% on-board with MS on this one, - not only this is a good practice to be consistent in language design (less limitations) by allowing programmer to use any name
 but this is a must-have feature i.e. you may code an assembly in Delphi Prism( as an example) and call a method "void" -
 then you'd need to consume it in C#. "void" is not a keyword in that language.

I personally think that purposely naming you stuff with "dangerous" names is a bad thing, but having verbatim name capability makes us feel more liberated :)


10 comments:

Anonymous said...

Adeline ROCKS?!

Sharon

Anonymous said...

Hey, I can't view your site properly within Opera, I actually hope you look into fixing this.

Anonymous said...

спасибо друг

Anonymous said...

Keep posting stuff like this i really like it

Anonymous said...

Couldnt agree more with that, very attractive article

Anonymous said...

I just added your blog site to my blogroll, I pray you would give some thought to doing the same.

Anonymous said...

Superb blog post, I have book marked this internet site so ideally I’ll see much more on this subject in the foreseeable future!

Anonymous said...

Finally, an issue that I am passionate about. I have looked for information of this caliber for the last several hours. Your site is greatly appreciated.

Anonymous said...

learned a lot

Anonymous said...

Wow this is a great resource.. I’m enjoying it.. good article