identifier out of scope

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm getting what I think is a very strange result in ASP.NET. I have code as
follows inside a method:

string tempCol = "1";
string tempStr = "2";

My code wasn't working properly so I stepped through the code and found that
as soon as I get past the first line of code and the debugger is ready to
execute the 2nd line, I can't see the tempCol variable at all. It is not in
the Locals area at of the debugger and if I put my mouse over it and do a
Quick Watch, it says, "error: identifier 'tempCol' out of scope". I'm not
sure how this can be since it is right on the previous line and should still
be in scope. Help, I'm checking into the twilight zone!!!
 
just guessing here, but...maybe the compiler realized that you were not
using the variable elsewhere in the script so optimized it out? Other than
that can't imagine how it could go out of scope on the very next line.
 
that is a good thought but unfortunately the variable is being used. i just
figured out that these variables are within an if statement and if i define
them outside the if-statement, they work fine. for example, i have

if (found)
{
string tempCol = "1";
string tempStr = "2";
 
Back
Top