user2925656 user2925656 - 1 year ago 79
C# Question

Avoid nested if for null and parameter condition

Is it possible to avoid nested if statements while I want to check if variable/object is null and if variable/object meet some condition eg.

var obj = "test";
do something;

Is it possible to do oneliner of this statement without defining own method which handle this ?

Answer Source

You can also try (in Java)


this way, you don't have to do an explicit null check,

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download