else or return?

后端 未结 19 588
故里飘歌
故里飘歌 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条回答
  •  -上瘾入骨i
    2021-01-01 13:55

    I tend to have a single point of exit, which is very useful when implementing locks in a multi-threaded environment, to make sure that the locks are released. With the first implementation, it's harder to do.

提交回复
热议问题