Hashtable.Item property

  • Thread starter Thread starter Andrew Chen
  • Start date Start date
A

Andrew Chen

Hi:

I've tried to use Hashtable.Item property, which should
return a value according to the key assigned. But it
returns an error saying the function does not exist in the
class (it did not show up under intellisense either when I
typed in the letter). Can someone tell me if this is a
bug and how do I fix that?

Andrew
 
Andrew Chen said:
Hi:

I've tried to use Hashtable.Item property, which should
return a value according to the key assigned. But it
returns an error saying the function does not exist in the
class (it did not show up under intellisense either when I
typed in the letter). Can someone tell me if this is a
bug and how do I fix that?

Andrew

The Hashtable.Item() property is an indexer. In C# indexers are accessed
using an array-like syntax:

Hashtable h = new Hashtable();
h["somekey"] = "somevalue";
Console.WriteLine( h["somekey"]);

For languages (like VB.NET) that do not support a special syntax for
indexers, the name is made available:

Dim h as new Hashtable()
h.Item( "somekey") = "somevalue"
Console.WriteLine( h.Item( "somekey"))
 
Back
Top