[Mono-list] Hashtable Item Property
Jonathan Pryor
jonpryor@vt.edu
Mon, 13 Oct 2003 21:04:45 -0400
Let me guess; you're trying to do this:
Hashtable h = new Hashtable ();
h.Item ("foo") = "bar";
object o = h.Item ("foo");
That's the bastardized C#/VB.NET hybrid language syntax. It is not
valid C# syntax. You want:
Hashtable h = new Hashtable ();
h["foo"] = "bar";
object o = h["foo"];
In other words, use (what looks like) an array access syntax instead of
using the Item() property.
Item() is for languages that don't support operator overloading. C#
supports operator overloading, and the array-access modifier is the way
to do what you want.
- Jon
On Mon, 2003-10-13 at 20:31, Hamza Karamali wrote:
> Has the Item property in System.Collections.Hashtable been implemented?
> Whenever I use it, I get an error like the following:
>
> Complex.cs(90) error CS0119: Expression denotes a `property access' where
> a `method group' was expected
>
> I downloaded the latest version of mcs, peeked in the Hashtable.cs file in
> .../class/corlib/System.Collections and couldn't find an Item property
> defined.
>
> Am I missing something?
>
> Thanks,
>
> Hamza.
>
> _______________________________________________
> Mono-list maillist - Mono-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list