So I made a grimey discovery yesterday and I want to share it here because this is a big gotcha. When I use the immediate window with C# I just type in whatever it is that I want to inspect and hit return. I started using the immediate window with VB.Net recently and I kept getting this meaningless error that read:
"Property access must assign to the property or use its value"This was very troubling to me at first because this is not the first time I have ever used the immediate window, so I then remembered that I had to do something with a question mark, but I thought that was only for the Command Window, apparently I was wrong... kind of.
This is a screen capture of my immediate window. The first line is the failure and the second line is the right way to do it with VB.Net.
I did a google search and I found this page: http://forums.asp.net/t/1091662.aspx/1
I had a head palm moment and realized that you are really supposed to use a "?" before your arguments in the immediate window. I never had to bother with this before for C#, it appears to only happen with VB.Net.
So the Gotcha of today is...
- When using an immediate window with VB.Net you are required to start your arguments with a question mark "?".
- When using an immediate window with C# you are not required in most instances to use a question mark before your arguments. I can't prove this, but if you look at this link http://msdn.microsoft.com/en-us/library/f177hahy(v=vs.90).aspx you will see that they show the example with VB.Net and don't bother with C#, I think that means something.
- When you want to evaluate a statement (IE: Set a value) in the immediate window with VB.Net, do not include the question mark "?" because you will just receive an unhelpful error. This is not required in C#.