Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Sorted StringDictionary

8 views
Skip to first unread message

Norbert Pürringer

unread,
Feb 22, 2008, 4:46:49 AM2/22/08
to
Hello,

I would like to use a strongly typed dictionary consisting of keys and
values of type string. Now there is a specialized StringDictionary,
but I need a sorted StringDictionary to enhance searching for keys.
Now would you recommend me to use a generic SortedDictionary<string,
string> instead of a specialized string dictionary?

What can be done to have a shorter notation of
SortedDictionary<string, string> in case of references, e.g.

StringDictionary<string, string> a = new StringDictionary<string,
string>(StringComparer..InvariantCultureIgnoreCase);

StringDictionary<string, string> b = a;

I found out, that the compiler does not have any problems, if the last
line is replaced by:

IDictionary b = a;

But how does the compiler know, that b consists of strongly typed
string keys and values, if following is implemented:

b.Add("Test", "Test");

Would you recommend me to use StringDictionary<string, string> instead
of IDictionary to add entries due to performance reasons?

Regards,
Norbert

Norbert Pürringer

unread,
Feb 22, 2008, 5:20:15 AM2/22/08
to

> StringDictionary<string, string> a = new StringDictionary<string,
> string>(StringComparer..InvariantCultureIgnoreCase);
>
> StringDictionary<string, string> b = a;

Sorry I meant SortedDictionary<string, string> a ...

0 new messages