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
The performance difference, if any, is negligible in any normal case.
One standard practice (among others) is to try to keep a single exit point from a method, so that talks in favour of the first alternative.
The actual implementation for the return
in the middle is most likely to make a jump to the end of the method, where the code to wrap up the stack frame for the method is, so it's likely that the final executable code is identical for the two codes.