Here is a great video from one of my buddies, Jeremy Clark, on generic constraints and default:
Here is an extension method I made from Jeremy’s second example:
public static T Max<T>(this T obj1, T obj2) where T : IComparable { if obj1.CompareTo(obj2) >= 0 ? return obj1 : return obj2; }
Discover more from dotNetTips.com
Subscribe to get the latest posts sent to your email.
