473,406 Members | 2,894 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,406 software developers and data experts.

HashMap or Property

Hi,
is there anything in the C# language that will allow you to retrieve a
value by a key, sort of like those in java? for instance

Object o = map.get("somekey");

i know there as to be something like this, but can't find it in
System.Utils. I have seen HashTable, but you must enumerate thru all
items and do a comparison until you find the key you are looking for
apparently.

thanks

Nov 17 '05 #1
3 52548
No you donot need to iterate over all the items in a hashtable, which is in
System.Collections namespace. You may use:
System.Collections.Hashtable hash = new System.Collections.Hashtable();
:
:
Object o = hash["somekey"];
HTH
Ashish

"farseer" <fa*****@optonline.net> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...
Hi,
is there anything in the C# language that will allow you to retrieve a
value by a key, sort of like those in java? for instance

Object o = map.get("somekey");

i know there as to be something like this, but can't find it in
System.Utils. I have seen HashTable, but you must enumerate thru all
items and do a comparison until you find the key you are looking for
apparently.

thanks

Nov 17 '05 #2
Ahh yes. thank you...i see it supports the IDictionary interface...

Nov 17 '05 #3

"farseer" <fa*****@optonline.net> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Ahh yes. thank you...i see it supports the IDictionary interface...


In .NET 2.0 you will probably want to use the generic type Dictionary
instead of HashTable.

- Michael S
Nov 17 '05 #4

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

Similar topics

2
by: dougjrs | last post by:
I have a HashMap that is storing form data that will later be inserted into a database. I have been able to create the HashMap just fine, but I wanted to be able to take my HashMap and just "dump"...
1
by: Christian Gollwitzer | last post by:
Hi, I'm trying to loop over the elements in a hashmap of the STL-implementation by SGI. The point is, that because the key/value pair is stored as std::pair in the COntainer, the code becomes...
4
by: David | last post by:
Hi, I have created the following HashMap class. class HashMap: public hash_map<string, string, HashString, HashStringCompare> { public: HashMap(): hash_map<string, string, HashString,...
2
by: xor | last post by:
I'm doing up a school project using java, and am a little new to it (I've worked with other languages for years though). I've seen code posted by the instructor using HashMap like this... ...
6
by: bumrag | last post by:
This is the car dealership object relating to the coursework, there is also a separate object named car that i think i need to link to. The problem is on the addcar() method. Any help would be...
4
by: panos100m | last post by:
Hi these are the conents of my hashmap printing out the entrySet. entrySet1: OrderDate=10/30/2007, entrySet2: Level_0={Item_0={ItemTotal= 3.99, ItemName=test® in, ShipDate=10/31/2007,...
15
by: lbrtchx | last post by:
Hi, ~ I have found myself in need of some code resembling a Hashmap ~ This is easily done in Java this way: ~ import java.util.*; // __ public class JMith00Test{
3
dlite922
by: dlite922 | last post by:
I could have this done in php in three lines of code but in Java here's what I need to do: English Looping through list of words I call a function that returns a HashSet of movie titles that...
1
by: evelina | last post by:
Hello, I need help. I have the following hashmap: HashMap<HashMap<Dimension, Integer>, String> mapList = new HashMap<HashMap<Dimension, Integer>, String>(); I want to extract Dimesion from the...
0
yoda
by: yoda | last post by:
So has the title says I need to find a away to loop over a Character ArrayList and replace the characters with a values from a HasMap. This is a simple encryption but I can't figure it out. What...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
agi2029
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,...

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.