Object - IsNull
A T extension method that query if '@this' is null.
public static void Main() { object thisNull = null; var thisNotNull = new object(); // C# Extension Method: Object - IsNull bool result1 = thisNull.IsNull(); // return true; bool result2 = thisNotNull.IsNull(); // return false; Console.WriteLine(result1); Console.WriteLine(result2); }
View Source
public static partial class Extensions { /// <summary> /// A T extension method that query if '@this' is null. /// </summary> /// <typeparam name="T">Generic type parameter.</typeparam> /// <param name="this">The @this to act on.</param> /// <returns>true if null, false if not.</returns> public static bool IsNull<T>(this T @this) where T : class { return @this == null; } }