Check if an object is not null in C#

By [)ia6l0 iii

Extension method to check if an object is not null

public static bool IsNotNull(this object o)
        {
            return (o != null);
        }

The above extension method can be applied on any object to check if it is not null. This method just makes the syntax easier and does not involve any performance improvements.

Related FAQs

Extension method to check if an object is null
Extension method to check if a string is null or empty
Check if an object is not null in C#  (3872 Views)