else or return?

后端 未结 19 896
故里飘歌
故里飘歌 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 14:05

    The return will cause the code to return from whatever method the if statement is in, no further code will be executed. The statement without the return will simply drop out of the if statement.

提交回复
热议问题