[Mono-list] StringDictionary Class

Marcus mathpup@mylinuxisp.com
Thu, 25 Nov 2004 23:05:21 -0600


Short version: The Item property is really an indexer, which permits 
array-like access to the data structure. For example, code fragment below 
should print ``Apple'':

		StringDictionary dict = new StringDictionary();
		dict.Add("a", "Apple");
		Console.WriteLine(dict["a"]);

Longer version: This is one of the cases where the C# representation differs 
from that of the underlying metadata. From C#'s perspective, properties do 
not have parameters, and they only have code associated with "getting" and 
"setting." The metadata that the CLI seems actually permits properties with 
zero or many parameters, even though C# does not directly support declaring 
them. In the case of StringDictionary, there is a property names Item, which 
takes a parameter. From C#'s perspective, this is an indexer.



On Thursday 25 November 2004 10:33 pm, Ryan wrote:
> I'm trying to use the System.Collections.Specialized.StringDictionary
> class but when I try to use
> the Item property it say it doesn't contain a definition for it. The
> documentation doesn't mark it as incomplete though. The same goes for
> ListDictionary.Item
>
> Are these incomplete or and I doing something wrong? I know I'm not
> mistyping it.