Is there a recommended way (according to .net Framework guidelines) of checking for null, example:
if (value == null)
{//code1}
else
{//code2}
or
if (value != null)
{//code2}
else
{//code1}
Or the both codes has same performance?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There is no performance difference, so you should strive for improved readability.
For example, it is often a good idea to put the more “regular” path in the
ifbranch, and put the “exceptional” one in theelsebranch.