Hi,
I'm trying to create a new Hashtable and use it:
System.Collecti ons.Hashtable hash_directory;
hash_directory. Item("blabla");
and here is the error message I get:
'System.Collect ions.Hashtable' does not contain a definition for 'Item'
any idea??
Thanks
Ilann 5 4448
See the online help under "HashTable.Item " and there is a note that says:
"In C#, this property is the indexer for the Hashtable class."
so use the indexer version:
hash_directory["blabla"]
ShaneB
"Ilann" <il***@free.f r> wrote in message
news:ef******** ******@tk2msftn gp13.phx.gbl... Hi,
I'm trying to create a new Hashtable and use it:
System.Collecti ons.Hashtable hash_directory;
hash_directory. Item("blabla");
and here is the error message I get:
'System.Collect ions.Hashtable' does not contain a definition for 'Item'
any idea??
Thanks
Ilann
"Ilann" <il***@free.f r> wrote in
news:ef******** ******@tk2msftn gp13.phx.gbl: Hi,
I'm trying to create a new Hashtable and use it:
System.Collecti ons.Hashtable hash_directory;
hash_directory. Item("blabla");
and here is the error message I get:
'System.Collect ions.Hashtable' does not contain a definition for 'Item'
any idea??
Thanks
Ilann
Ilann,
You must first create an instance of the hashtable before it can be
used:
Hashtable hash_directory = new Hashtable();
Please see the help file entry for System.Collecti ons.Hashtable for
some example code.
--
Hope this helps.
Chris.
-------------
C.R. Timmons Consulting, Inc. http://www.crtimmonsinc.com/
and Hashtable is a class that implements IDictionary interface, so there
should a Key/Value pair in Hashtable.
for example: hash["blahKey"] = "blahValue" ;
Maqsood Ahmed
Kolachi Advanced Technologies http://www.kolachi.net
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Chris R. Timmons <crtimmons@X_NO SPAM_Xcrtimmons inc.com> wrote: I'm trying to create a new Hashtable and use it:
System.Collecti ons.Hashtable hash_directory;
hash_directory. Item("blabla");
and here is the error message I get:
'System.Collect ions.Hashtable' does not contain a definition for 'Item'
any idea??
You must first create an instance of the hashtable before it can be used:
Hashtable hash_directory = new Hashtable();
While that's true, it's not the reason for the error message. The error
message is because C# doesn't use named properties like that; it uses
the "default" property for a class as an indexer:
object o = hash_directory["blabla"];
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jon Skeet [C# MVP] <sk***@pobox.co m> wrote in
news:MP******** *************** *@msnews.micros oft.com: Chris R. Timmons <crtimmons@X_NO SPAM_Xcrtimmons inc.com> wrote: > I'm trying to create a new Hashtable and use it: > > System.Collecti ons.Hashtable hash_directory; > > hash_directory. Item("blabla"); > > and here is the error message I get: > > 'System.Collect ions.Hashtable' does not contain a definition > for 'Item' > > any idea??
You must first create an instance of the hashtable before it can be used:
Hashtable hash_directory = new Hashtable();
While that's true, it's not the reason for the error message. The error message is because C# doesn't use named properties like that; it uses the "default" property for a class as an indexer:
object o = hash_directory["blabla"];
Jon,
Yeah, I know. Rather than re-type what's already readily available
in the help file, I decided to just direct him there.
Chris.
-------------
C.R. Timmons Consulting, Inc. http://www.crtimmonsinc.com/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: francois |
last post by:
First of all I would to to apologize for resending this post again but I
feel like my last post as been spoiled
Here I go for my problem:
Hi,
I have a webservice that I am using and I would like it to return an XML
serialized version of an object.
|
by: Cyrus |
last post by:
I have a question regarding synchronization across multiple threads for a
Hashtable. Currently I have a Threadpool that is creating worker threads
based on requests to read/write to a hashtable. One function of the
Hashtable is to iterate through its keys, which apparently is inherently not
thread-safe. Other functions of the Hashtable include
adding/modifying/deleting.
To solve the synchronization issues I am doing two things:
1. Lock...
|
by: SenthilVel |
last post by:
how to get the corresponding values for a given Key in hashtable ??
|
by: Ken |
last post by:
I have a C# Program where multiple threads will operate on a same Hashtable.
This Hashtable is synchronized by using Hashtable.Synchronized(myHashtable)
method, so no further Lock statements are used before adding, removing or
iterating the Hashtable. The program runs in a high workload environment.
After running a few days, now it suddenly catchs this Exception when
inserting a pair of key and object,
stacktrace =...
|
by: Sreekanth |
last post by:
Hello,
Is there any better collection than HashTable in terms of performance, when
the type of the key is integer?
Regards,
Sreekanth.
| |
by: Fred |
last post by:
I'm trying to build a hashtable and a arraylist as object value
I'm not able to retrieve stored object from the hashtable.
Hashtable mp = new Hashtable(); // THE HASHTABLE
ArrayList atemp = new ArrayList(); // THE ARRAY
StreamWriter sw = new StreamWriter(@"C:\temp\fred.html");
|
by: Robin Tucker |
last post by:
When I create a hashtable hashing on Object-->Item, can I mix "string" and
"integer" as the key types? I have a single thumbnail cache for a database
with (hashed on key) and a file view (hashed on string). So, for example,
when I want to know if the file "xyz.abc" is in the cache, I can write
myTable.ContainsKey ( "xyz.abc" ) or if a given DB key is in the hash I can
write myTable.ContainsKey ( 123 ). Or do the keys all have to be of...
|
by: SevDer |
last post by:
Hi
We have a static hashtable that is located in another tier in our n-tiered
web application.
And we are storing big but not huge objects in this hashtable and the key to
the objects is through Session.SessionID.
public class DataStore : System.Web.UI.Page
{
public static Hashtable ht = new Hashtable();
|
by: PAzevedo |
last post by:
I have this Hashtable of Hashtables, and I'm accessing this object from
multiple threads, now the Hashtable object is thread safe for reading,
but not for writing, so I lock the object every time I need to write to
it, but now it occurred to me that maybe I could just lock one of the
Hashtables inside without locking the entire object, but then I thought
maybe some thread could instruct the outside Hashtable to remove an
inside Hashtable...
|
by: archana |
last post by:
Hi all,
I am having one confusion regarding hashtable.
I am having function in which i am passing hashtable as reference. In
function i am creating one hashtable which is local to that function.
Then i am setting this hash table to hashtable which i am passing as
ref.
So my question is how scope is mention when i am assigning local
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
| |
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |