I am currently developing an Order Entry application in C#. The order entry process follows a wizard-like format.
We have a class, WizardBase, that contains the screen to display.
At one point, I had enabled /unsafe code in the project properties. I had also enabled Optimized Code.
One of my team members noticed that he couldn't properly declare variables in any function. We tried, and the variable declaration was sporadic at best, most times it didn't work at all. Here's an example of what I am saying:
int i = 0;
Breaking on this declaration and viewing i in the watch window, would report "i does not exist in the current context."
And now, we have a persistent variable, 'a', that is an object, and it has the following members:
base
nonpublic-members
-d = a.b - a.b
-e = a.c - a.c
-f = a.c - a.c
-g = 1385422863972036620 - long
After extensive searching through our project, we have determined that nowhere in the project is an object of 'a' declared, furthermore there are no d's, e's, f's, or g's, and that number assigned to g is strange.
This is the wierdest thing I have ever seen in Visual Studio. Anyone seen something like this

Ghost Variables?
Jakobdo
This is because everything is optimized and most of the things are re-arrenged for better preformance.
When you unset the flag, you don't have any problems at all
Chris Langsenkamp
Further investigation has revealed the following:
The object a.a has a value of a.a and is a type of a.a
a.a - a.a - a.a
It can also expand and it has the following member:
a.b - System.ValueType - System.ValueType
This is true for a number of items. Also of note, is the fact that a.d, a.e, a.f, and a.g all have a lock icon next to them, with a small 'i' in front of it.
Does anyone have a clue what is going on
I have been unable to reproduce the problem in a blank project, but will soon try with a project compiled with /unsafe and optimized code.
Daniel Gary