473,386 Members | 1,743 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

No Hashtable.Get(key) method?

Hello,

I´m trying to implement a "reverse index table" using a hashtable.

But in the hashtable class i cannot find any get-Method.
The Java class of hashtable for example provides a method:
get(Object key)

Isn´t there any method in C# too?

If not... how to retrieve a value of a specific key?

And another question...

As I wrote, I have to implement a reverse index table.

This means that I have a class called "Document" and keys as int values.
I have to assign several Documents to one key. How would you do that to
get a most performant way?

My plan was to use a Hashtable in combination with a List.
Means I have int as keys for my Hashtable and putting my Document
objects into a List which I put into the Hashtable as value to a
specific key.

Is this a good idea?
I thought it very performant, because you can search very fast in a
Hashtable.

Regards,

Martin
Sep 11 '06 #1
4 22791
Martin Pöpping wrote:
But in the hashtable class i cannot find any get-Method.
The Java class of hashtable for example provides a method:
get(Object key)

Isn´t there any method in C# too?
C# support the syntax:

yourhastableobject[thekey]

Arne
Sep 11 '06 #2
Martin Pöpping wrote:
This means that I have a class called "Document" and keys as int values.
I have to assign several Documents to one key. How would you do that to
get a most performant way?

My plan was to use a Hashtable in combination with a List.
Means I have int as keys for my Hashtable and putting my Document
objects into a List which I put into the Hashtable as value to a
specific key.

Is this a good idea?
I thought it very performant, because you can search very fast in a
Hashtable.
Hashtable of ArrayList is a known data structure.

Sounds OK to me.

If you are on .NET 2.0 then you should use Dictionary of List
ofcourse !

Arne
Sep 11 '06 #3
The default indexor will do this ...
MyHash[key] or you can use the Item property
http://msdn2.microsoft.com/en-us/lib...able.item.aspx

Cheers,

Greg

"Martin Pöpping" <ma******@despammed.comwrote in message
news:ee**********@newsreader2.netcologne.de...
Hello,

I´m trying to implement a "reverse index table" using a hashtable.

But in the hashtable class i cannot find any get-Method.
The Java class of hashtable for example provides a method:
get(Object key)

Isn´t there any method in C# too?

If not... how to retrieve a value of a specific key?

And another question...

As I wrote, I have to implement a reverse index table.

This means that I have a class called "Document" and keys as int values.
I have to assign several Documents to one key. How would you do that to
get a most performant way?

My plan was to use a Hashtable in combination with a List.
Means I have int as keys for my Hashtable and putting my Document objects
into a List which I put into the Hashtable as value to a specific key.

Is this a good idea?
I thought it very performant, because you can search very fast in a
Hashtable.

Regards,

Martin

Sep 11 '06 #4
Just use the indexer eg.

table[key]

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Martin Pöpping" <ma******@despammed.comwrote in message
news:ee**********@newsreader2.netcologne.de...
Hello,

I´m trying to implement a "reverse index table" using a hashtable.

But in the hashtable class i cannot find any get-Method.
The Java class of hashtable for example provides a method:
get(Object key)

Isn´t there any method in C# too?

If not... how to retrieve a value of a specific key?

And another question...

As I wrote, I have to implement a reverse index table.

This means that I have a class called "Document" and keys as int values.
I have to assign several Documents to one key. How would you do that to
get a most performant way?

My plan was to use a Hashtable in combination with a List.
Means I have int as keys for my Hashtable and putting my Document objects
into a List which I put into the Hashtable as value to a specific key.

Is this a good idea?
I thought it very performant, because you can search very fast in a
Hashtable.

Regards,

Martin

Sep 11 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

24
by: el_roachmeister | last post by:
Is there a way to make a text link post to a form without passing all the parameters in the url? The urls tend to get very long and messy. I often wonder if there is a limit to how long they can...
11
by: Egor Bolonev | last post by:
saluton al ciuj i know how to get item by key ================== dict = {10 : 50, 2 : 12, 4 : 43} print dict >> 12
2
by: Marcin Zmyslowski | last post by:
Hello! I have exceeded the length of the URL limit. I have a form where I send data using GET method. Now I have to change method of posting data into POST method. But please tell me how to get...
2
by: juli jul | last post by:
Hello I want to write get method of some object I create in other class: I am doing some like that: public ABC { get { return ABC; }
3
by: Sarraipa | last post by:
Hi! I want to get key events but not from an Object like System.Windows.Forms I want to get it directly from the keyboard independently of the Windows application that would be active at the...
1
by: jidixuelang | last post by:
aj.get = function(targetUrl, resultHandle) { aj.targetUrl = targetUrl; aj.XMLHttpRequest.onreadystatechange = aj.processHandle; aj.resultHandle = resultHandle; if(window.XMLHttpRequest) {...
5
by: JohnDriver | last post by:
Hi, I am having a form which has a text box and 3 radio buttons. I am using GET method in Ajax to pass the value. I can pass the value of the textbox fine but how to pass the value of radio...
5
sid0404
by: sid0404 | last post by:
Hi I am new to the visualstudio.net I am trying to develop an application which requires me to send data to a HTML webpage - http://patft.uspto.gov/netahtml/PTO/search-bool.html and the user...
9
by: magix | last post by:
If I have <form action="process.asp" method="get" name="form1"> .... .... <input TYPE=checkbox name=sports VALUE=Cricket> <input TYPE=checkbox name=sports VALUE=Swimming> <input...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
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,...
0
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...
0
Oralloy
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,...
0
jinu1996
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.