Object - IsDefault
A T extension method that query if 'source' is the default value.
public static void Main() { int intDefault = 0; int intNotDefault = 1; // C# Extension Method: Object - IsDefault bool result1 = intDefault.IsDefault(); // return true; bool result2 = intNotDefault.IsDefault(); // return false; Console.WriteLine(result1); Console.WriteLine(result2); }
View Source
public static partial class Extensions { /// <summary> /// A T extension method that query if 'source' is the default value. /// </summary> /// <typeparam name="T">Generic type parameter.</typeparam> /// <param name="source">The source to act on.</param> /// <returns>true if default, false if not.</returns> public static bool IsDefault<T>(this T source) { return source.Equals(default(T)); } }