else or return?

后端 未结 19 813
故里飘歌
故里飘歌 2021-01-01 13:27

Which one out of following two is best wrt to performance and standard practice. How does .NET internally handles these two code snippets?

Code1

If(r         


        
19条回答
  •  感情败类
    2021-01-01 13:49

    I would use Code 1, because if I add something later after the if statement, I'm still positive it will execute, without me needing to remember to remove the return clause from where it is in Code 2.

提交回复
热议问题