topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Tuesday March 19, 2024, 1:35 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Last post Author Topic: C# & Visual Studio Problem  (Read 13888 times)

mwb1100

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,645
    • View Profile
    • Donate to Member
Re: C# & Visual Studio Problem
« Reply #25 on: January 16, 2011, 11:37 AM »
So, just to be clear, the *program* works fine if you have a constant `false` controlling the `if` - the problem is that the debugger is unable to deal correctly with variables scoped to the `else` clause.  Is that a fair summary?

kyrathaba

  • N.A.N.Y. Organizer
  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 3,200
    • View Profile
    • Donate to Member
Re: C# & Visual Studio Problem
« Reply #26 on: January 16, 2011, 02:41 PM »
WTF? It's normal again...

Has anyone heard of this kind of wonkiness before?

Yes, I have.  Per discussion with a tech of MSDN, it's a bug in the Debugger.

Renegade

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 13,288
  • Tell me something you don't know...
    • View Profile
    • Renegade Minds
    • Donate to Member
Re: C# & Visual Studio Problem
« Reply #27 on: January 16, 2011, 04:41 PM »
So, just to be clear, the *program* works fine if you have a constant `false` controlling the `if` - the problem is that the debugger is unable to deal correctly with variables scoped to the `else` clause.  Is that a fair summary?

Yes.

"if (false)" results in locally scoped variables declared in else clauses not being available to the debugger, but still functioning properly in the software.

Here's something you can copy & paste in VS to have a quick look:
Code: C# [Select]
  1. string test1a = "Hello";
  2. int test2a = 4;
  3. string test1c;
  4. int test2c;
  5. if (false)
  6. {
  7. }
  8. else
  9. {
  10.     string test1b = test1a + " world!"; // can't see 1b
  11.     int test2b = test2a * test2a; // can't see 2b
  12.     test1c = test1b; // can see 1c, not 1b
  13.     test2c = test2b; // can see 2c, not 2b
  14.     Console.WriteLine("Break here :" + test1b + test2b.ToString()); // this works as expected, but can't see during debugging
  15. }
Slow Down Music - Where I commit thought crimes...

Freedom is the right to be wrong, not the right to do wrong. - John Diefenbaker