Boolean types

前端 未结 10 2022
时光说笑
时光说笑 2021-01-22 11:54

During code review I discovered many places of our C# code that looks like this:

if(IsValid()) {
     return true;
}
else {
     return false;
}
<
10条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-22 12:36

    I even sometimes see this some of the legacy code I maintain:

    bool retValue;
    if (IsValid()) 
    {
        retValue = true;
    }
    else 
    {
        retValue = false;
    }
    
    return retValue;
    

    Are some programmers paid by the character?

提交回复
热议问题