I was getting annoyed with ConfigurationElementCollection returning IEnumerable and not IEnumerable<T>, after some Googling I came across this post on StackOverflow http://stackoverflow.com/questions/7991252/read-web-config-section-to-list.
Basically you implement IEnumerable<T> and in GetEnumerator do this
1: public new IEnumerator<T> GetEnumerator()
2: {
3: return this.OfType<T>().GetEnumerator();
4: }
No more casting when you want to use Linq on the ConfigurationElementCollection
No comments:
Post a Comment