sortedDictionary.Item ?

M

mp

according to the help
(http://msdn.microsoft.com/en-us/library/f7fta44c.aspx)
Sorteddictionary has a property Item by which you can retrieve the value for
that key
"Gets or sets the value associated with the specified key."

however when it try it in code, no Item property exists
seems like i should be able to do this:
SortedDictionary<string, string> test = new SortedDictionary<string,
string>();
test.Add("a","B");
debug.print (test.Item("a"));

but i can't
what am i missing?
 
M

mp

Peter Duniho said:
[...]
seems like i should be able to do this:
SortedDictionary<string, string> test = new SortedDictionary<string,
string>();
test.Add("a","B");
debug.print (test.Item("a"));

but i can't
what am i missing?

Maybe just reading the documentation. From the relevant page
(http://msdn.microsoft.com/en-us/library/7w6691xh.aspx):

This property provides the ability to access a specific element
in the collection by using the following C# syntax:
myCollection[key]

Did you try doing what the documentation says to do? :)

Pete

I saw that part after posting, sorry,
still, if it has an Item property, why doesn't it come up in intellisense?
thanks
mark
 
K

kndg

[...]
I saw that part after posting, sorry,
still, if it has an Item property, why doesn't it come up in intellisense?
thanks
mark

It has, but you can't access it in c# (it gets translated to indexer).
Try coding with other language (VB for example). It will come up in
intellisense.
 
M

mp

kndg said:
[...]
I saw that part after posting, sorry,
still, if it has an Item property, why doesn't it come up in
intellisense?
thanks
mark

It has, but you can't access it in c# (it gets translated to indexer).
Try coding with other language (VB for example). It will come up in
intellisense.

thanks
mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top