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
If you remove the braces around the 2nd version's remaining code, that's exactly what I use. I prefer to make the early validation part of a function obvious, and then I can get down to business.
That being said, it's a matter of opinion. As long as you're consistent about it, pick one and stick with it.
edit: About the performance, the emitted IL is exactly the same. Choose one or the other for the style, there is no penalty to either.