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