mail-archives/mono-list/2003-October/016376.html

97 строки
3.3 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE> [Mono-list] Hashtable Item Property
</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:jonpryor%40vt.edu">
<META NAME="robots" CONTENT="index,nofollow">
<LINK REL="Previous" HREF="016375.html">
<LINK REL="Next" HREF="016377.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[Mono-list] Hashtable Item Property
</H1>
<B>Jonathan Pryor
</B>
<A HREF="mailto:jonpryor%40vt.edu"
TITLE="[Mono-list] Hashtable Item Property">jonpryor@vt.edu
</A><BR>
<I>Mon, 13 Oct 2003 21:04:45 -0400</I>
<P><UL>
<LI> Previous message: <A HREF="016375.html">[Mono-list] Hashtable Item Property
</A></li>
<LI> Next message: <A HREF="016377.html">[Mono-list] Profiler of the runtime
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#16376">[ date ]</a>
<a href="thread.html#16376">[ thread ]</a>
<a href="subject.html#16376">[ subject ]</a>
<a href="author.html#16376">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE>Let me guess; you're trying to do this:
Hashtable h = new Hashtable ();
h.Item (&quot;foo&quot;) = &quot;bar&quot;;
object o = h.Item (&quot;foo&quot;);
That's the bastardized C#/VB.NET hybrid language syntax. It is not
valid C# syntax. You want:
Hashtable h = new Hashtable ();
h[&quot;foo&quot;] = &quot;bar&quot;;
object o = h[&quot;foo&quot;];
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:
&gt;<i> Has the Item property in System.Collections.Hashtable been implemented?
</I>&gt;<i> Whenever I use it, I get an error like the following:
</I>&gt;<i>
</I>&gt;<i> Complex.cs(90) error CS0119: Expression denotes a `property access' where
</I>&gt;<i> a `method group' was expected
</I>&gt;<i>
</I>&gt;<i> I downloaded the latest version of mcs, peeked in the Hashtable.cs file in
</I>&gt;<i> .../class/corlib/System.Collections and couldn't find an Item property
</I>&gt;<i> defined.
</I>&gt;<i>
</I>&gt;<i> Am I missing something?
</I>&gt;<i>
</I>&gt;<i> Thanks,
</I>&gt;<i>
</I>&gt;<i> Hamza.
</I>&gt;<i>
</I>&gt;<i> _______________________________________________
</I>&gt;<i> Mono-list maillist - <A HREF="mailto:Mono-list@lists.ximian.com">Mono-list@lists.ximian.com</A>
</I>&gt;<i> <A HREF="http://lists.ximian.com/mailman/listinfo/mono-list">http://lists.ximian.com/mailman/listinfo/mono-list</A>
</I>
</PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI> Previous message: <A HREF="016375.html">[Mono-list] Hashtable Item Property
</A></li>
<LI> Next message: <A HREF="016377.html">[Mono-list] Profiler of the runtime
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#16376">[ date ]</a>
<a href="thread.html#16376">[ thread ]</a>
<a href="subject.html#16376">[ subject ]</a>
<a href="author.html#16376">[ author ]</a>
</LI>
</UL>
</body></html>