This article examines the significance of extension methods in .NET, emphasizing their role in enhancing existing types without altering source code. It also introduces Extension Members in .NET 10 (C# 14), allowing the addition of both methods and properties, thus expanding developers' capabilities. While there are limitations, they improve code maintainability and flexibility.
Tag: extension method
Using Generic Constraints & Default
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; }
