By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,992 Members | 1,147 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,992 IT Pros & Developers. It's quick & easy.

SortedList<> and SortedDictionary<>

P: n/a

Why does the generic SortedList and generic SortedDictionary not define any
virtual members?

Thanks,
Michael
May 14 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"Michael Primeaux" <mj********@msn.com> wrote:
Why does the generic SortedList and generic SortedDictionary not define any
virtual members?


The classes in the System.Collections.Generics namespace are designed to
be efficient for users who need them to be efficient. Non-virtual
methods are easier to inline (usually it is impossible to inline virtual
method calls) and are faster to call (less indirections are needed).

It's generally recommended that you use composition rather than
inheritance to get extra collection behaviours. You can still implement
IDictionary, IList and friends to support polymorphic behaviour where
required.

System.Collections.ObjectModel has some containers more suitable for
inheritance.

-- Barry
May 14 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.