Condition false, but code inside the if statement executed

前端 未结 3 1874
醉梦人生
醉梦人生 2020-12-19 22:55

I have the following method:

public bool ConnectAsync()
{
    if (IsConnected)
        throw new InvalidOperationException(\"Socket is already connected\");
         


        
3条回答
  •  别那么骄傲
    2020-12-19 23:32

    The Expression window you have in the debugger is the one triggering the exception, not your code. Remove expressions (or watch) and it should work as expected.

提交回复
热议问题