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

Best way to handle NULL

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

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

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 –


February 16, 2011 - Posted by | .NET General

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: