//Cloud notes from my desk -Maheshk

"Fortunate are those who take the first steps.” ― Paulo Coelho

Best way to handle NULL

Hi,
Let say, you are going to check for null. Which one you prefer?
Option #1

if (sender == null) return;
// Code goes here

or
Option #2
if (sender != null)
{
// Code goes here
}

Which option you prefer ?
Which one is recommended in handling NULL ?
Which is actually recommended by Microsoft ?
What option is used in Framework libraries ?

Answer: Options #1 is recommended, simply for readability. I dont see any difference

Read more about this – http://stackoverflow.com/questions/3812984/best-way-to-handle-a-null

2011-02-16 Posted by | .NET General | Leave a comment