else or return?

后端 未结 19 891
故里飘歌
故里飘歌 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:58

    Can't say about performance, but Code 1 looks a lot clearer and more logical to me. Jumping out of a function in the middle of an if block appears quite confusing and is easy to overlook.

提交回复
热议问题