Should I use `!IsGood` or `IsGood == false`?

后端 未结 30 2444
礼貌的吻别
礼貌的吻别 2020-12-02 19:49

I keep seeing code that does checks like this

if (IsGood == false)
{
   DoSomething();
}

or this

if (IsGood == true)
{
   D         


        
30条回答
  •  隐瞒了意图╮
    2020-12-02 20:46

    If you really think you need:

    if (Flag == true)
    

    then since the conditional expression is itself boolean you probably want to expand it to:

    if ((Flag == true) == true)
    

    and so on. How many more nails does this coffin need?

提交回复
热议问题