Check if an object is null in C#

By [)ia6l0 iii

Extension method to check if an object is null

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

The above extension method can be applied on any object to check if it is 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 not null
Check if an object is null in C#  (4552 Views)