Hashtable.Item property

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
 
M

MikeB

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"))
 

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