Hashtable Item in C#

  • Thread starter Thread starter Anony
  • Start date Start date
A

Anony

Hi All,

I used the Hashtable.Item in VB.Net, i.e.

Dim Tables As New Hashtable
Tables.Item(ID) = objTable

Now, I tried the same in C#, and got an error says the Hashtable has no Item
property.

Hashtable Tables = new Hashtable();
Tables.Item(ID) = objTable;

Did I miss something or I have to use Tables.Add(ID, objTable); in C#?


Thanks for any tips,
Anony
 
In c# use the square brackets instead of the round ones


Hashtable tables = new Hashtable()

tables[ID] = objTable


Cheers,

A
 
Use it this way:
Tables(ID) = objTable

There is no Item property in C#; instead we have indexers.
 
Back
Top