Conditional breakpoint in Visual Studio

Just like in code, you need to use:

MyStringVariable == "LKOH"

The double-equals is the key. Without it, it's saying it can't evaluate because your expression doesn't evaluate to a boolean.


if (MyStringVariable == "LKOH") Debugger.Break();

you'll need System.Diagnostics namespace

http://msdn.microsoft.com/en-us/library/system.diagnostics.debugger.break.aspx


Sample code:

static void Main(string[] args) {
  string myvar;
  for (int ix = 0; ix < 10; ++ix) {
    if (ix == 5) myvar = "bar"; else myvar = "foo";
  }    // <=== Set breakpoint here
}

Condition: myvar == "bar"

Works well.