tags:

views:

179

answers:

1

I've written a class that inherits from ObservableCollection<T>. I would like to be able to use the LINQ extensions methods like FirstOrDefault, like what you may get if you inherit from an implementation of IEnumerable<T>, or List<T>. How would I accomplish this?

A: 

ObservableCollection is based on Collection which implements IEnumerable. You are probably just missing the using statement.

You might find it useful to use a VS addon like resharper which works all these things out for you, suggests fixes, improvements etc to your code (e.g. you type .First() and a tooltip appears saying "press alt+enter to add a reference to System.Linq") very very handy. I could never live without it now.

Michael Baldry
That is a using *directive* - a using *statement* is the IDisposable thing.
Marc Gravell