The Gotcha
When moving VB.Net code to C# code that uses the My namespace such as “My.Request” the equivalent for you to use is “HttpContext.Current.Request”. Pretty much you can assume that all of the properties exposed from “My” is actually something else, somewhere else. Good luck finding them and matching everything up properly, it is a pain in the ass.

This link should help: http://msdn.microsoft.com/en-us/library/ms172990(v=vs.80).aspx
On the left hand side it has a listing of all of the My.* stuff. If you click on them it will tell you what the actual underlying class is that is being used.

The Gripe
This took me a good 1-2 hours to figure out and I am little steamed about it. This yet one more reason why I don’t like VB.Net, VB.Net is too friendly with some of its naming conventions and it will mask really important information such as the origins of a property.

I am converting a VB.Net Web Site over to a C# Web Application and I was having a bitch of a time figuring out what the hell “My” meant. There is no equivalent for “My” in C#, which in my opinion is preferable. I would rather use the full qualification vs. some arbitrary shortcut that is only good in one language.

Leave a Reply

Your email address will not be published. Required fields are marked *