As you may already know C# support type interfaces for generic methods. I have seen many developers write code like below for both extension methods and generic methods.
public static bool IsGreaterThan<T>(T x, T y) where T : IComparable<T> { if (x.CompareTo(y) > 0) { return true; } return false; }
Extension method:
public static bool IsGreaterThanExt<T>(this T x, T y) where T : IComparable<T> { if (x.CompareTo(y) > 0) { return true; } return false; }
The Usage:
Console.WriteLine(IsGreaterThan<int>(4, 3)); Console.WriteLine(4.IsGreaterThanExt<int>(3));
The above is redundant. The reason is that the type is automatically inferred by the C# compiler.
Now you can simply call the methods without the type
Console.WriteLine(IsGreaterThan(4, 3)); Console.WriteLine(4.IsGreaterThanExt(3))