The variable does not exist in the context, but it is clearly defined

In the image below, you can see that I am debugging my code and the variable y1

needs to be defined. However, I don't get any exceptions and the variable doesn't seem to exist! Why doesn't visual studio recognize my variable? I believe there must be a problem with my installation; can anyone else confirm?

enter image description here

Ref. http://i.imgur.com/RO7oqZ6.gif

+3


source to share


1 answer


The compiler can prove that the variable is never readable, so it doesn't even try to create it as it knows it is never used. If you change your code to actually use the variable, there will be no optimization and you can observe the variable through the debugger.



+8


source







All Articles