Local variables or direct statements?

前端 未结 7 1548
旧时难觅i
旧时难觅i 2021-01-25 23:55

I am currently studying C# and I really want to get a good coding style from the beginning, so I would like to hear opinions from you professionals on this matter.

Shoul

7条回答
  •  暖寄归人
    2021-01-26 00:25

    As you said you are studying C#

    So my vote will be this style for you

    bool parseSuccess = double.TryParse(stringToParse, out dblValue);
    if (parseSuccess) ...
    

    If you are studying you will have lot to learn and the above style clearly tells you that TryParse return a bool, so you won't have to worry or find whats the return type for TryParse

提交回复
热议问题