Coding Power Unleashed – Since C# 3.0 you can write extension methods on any class that you want, even if you don’t have the source code of the class. In other words you can extend a class with your own methods. Extension methods can only be declared in static classes as static methods. Extensions on List<T> classes can be very handy and make your code more readable and fluent. Suppose you have this mixed Animal list with Dogs and Cats from this blogpost. List<Animal> animalList = new List<Animal>(); animalList.Add(new Dog("Dog1", ConsoleColor.Red)); animalList.Add(new ...
Visits by Source
Users who voted for this posting