?: ?? Operators Instead Of IF|ELSE

前端 未结 9 1658
粉色の甜心
粉色の甜心 2020-11-28 02:09
public string Source
{
    get
    {
        /*
        if ( Source == null ){
            return string . Empty;
        } else {
            return Source;
                


        
9条回答
  •  猫巷女王i
    2020-11-28 03:01

    The ternary operator (?:) is not designed for control flow, it's only designed for conditional assignment. If you need to control the flow of your program, use a control structure, such as if/else.

提交回复
热议问题