Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I want to create a class that inherits from CollectionBase, but it seems that it does not support LINQ extensions!

Is it still supported? Or is there an alternative solution?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
141 views
Welcome To Ask or Share your Answers For Others

1 Answer

It is still supported, but it is obsolete. You should always prefer to use the collections defined in the System.Collections.Generic or the System.Collections.ObjectModel namespaces, instead.

You can inherit from one of the generic collections to create your own custom, strongly-typed collection, as well. And it will have full support for LINQ, since they already implement IEnumerable<T>.
Either List<T> or Collection<T> are good options for your case.

Avoid the non-generic collections like CollectionBase, ArrayList, and HashTable if at all possible. There is a performance penalty to using them, and they offer few advantages (if any!) over the generic versions that were introduced in more recent versions of the framework.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...