Cyberiafreak

"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

Advertisements

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:

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: