Confusing If Statement?

前端 未结 13 893
-上瘾入骨i
-上瘾入骨i 2020-12-20 13:03

I always use If statement (In C#) as (1. Alternative);

if (IsSuccessed == true)
{
   //
}

I know that there is no need to write \"== true\"

13条回答
  •  再見小時候
    2020-12-20 13:04

    What i see most is: (what I do)

    if (IsSuccessed)
    {
       //
    }
    

    and as alternative for in C++, for C# it's not needed (see comment):

    if (true == IsSuccessed)
    {
       //
    }
    

    The alternative is to prevent yourself for making the mistake to assign instead of compare. (= vs ==)

提交回复
热议问题