Extension methods illustrated
- π
- π 480 words
- π 3 minutes
- π¦ .NET
- π·οΈ C#
- π¬ 6 responses
Extension methods are a great new feature in the .NET Framework 3.5 that let you write new methods that appear to be part of existing classes without the need to subclass or modify them.
We can explain this in simple terms with an example. Here is a useful routine that takes a string and returns what it finds between two other strings that works just fine with .NET 2.0 and .NET 1.1.