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?
views:
179answers:
1
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
2010-01-27 21:50:13
That is a using *directive* - a using *statement* is the IDisposable thing.
Marc Gravell
2010-01-27 22:07:29