Lets says you have a collection of strings representing email addresses in a MailAddressCollection. You want to add them to another MailAddressCollection you have to loop through them one item at a time.
Why doesn’t MailAddressCollection have an AddRange function like a sensible collection? Well, probably because there is nothing in the collection contract that says that it should. ICollection<T> only requires that an Add method be defined. With extension methods, that should be enough. Just hook into a generic AddRange method defined as such:
Now when you call it, you get a nice and clean one-liner. And not just for MailAddressCollection, but for every class that implements ICollection<T>. Alas it doesn’t work on older collections that only implement ICollection, as that version doesn’t have an Add method.
Ok, so what’s all this belly-aching about? Somehow this obvious little timesaver is missing from the numerous extension methods we got when LINQ was released.