开发者

How to make Linq extension methods available on ObservableCollection<T>

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 y开发者_运维知识库ou inherit from an implementation of IEnumerable<T>, or List<T>. How would I accomplish this?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜