Hi all,
Is it ok to use a string as the key for Hashtable entries? I want to use
the name of entity in question, which I know will always be unique.
Do I have to do anything fancy equality-wise or are there any caveats I should
be aware of?
Thanks to anyone who can advise.
Kindest Regards
tce 6 3770
> Is it ok to use a string as the key for Hashtable entries?
yes, it is ok to use strings, i do it all the time. the comparison is case
sensitive, so if you want to have case insensitive keys, then drive your key
strings to upper case (or lower if you prefer).
AMercer wrote: Is it ok to use a string as the key for Hashtable entries?
yes, it is ok to use strings, i do it all the time. the comparison is case sensitive, so if you want to have case insensitive keys, then drive your key strings to upper case (or lower if you prefer).
Or use a case insensitive comparison fn.
<http://msdn.microsoft. com/library/default.asp?url =/library/en-us/cpref/html/frlrfsystemcoll ectionscaseinse nsitivehashcode providerclassto pic.asp>
-- www.midnightbeach.com
Jon,
It seems for me easier to use consequently
..ToLower
I hope that I don't miss something
Cor
"Cor Ligthert [MVP]" wrote: It seems for me easier to use consequently .ToLower
I hope that I don't miss something
Easier, maybe, but not always desirable. Using a case-insensitive
comparison function allows semantics like file names: Case doesn't
matter, but is preserved.
If I use "Jon Shemitz" as a key, I might prefer to get back "Jon
Shemitz" when I enumerate the Keys, not "jon shemitz" or "JON
SHEMITZ".
-- www.midnightbeach.com
"Cor Ligthert [MVP]" wrote: I don't know what program language you use, however in VBNet is for that as well a function.
http://msdn.microsoft.com/library/de...vconstants.asp
It is usable in C# as well of course by setting a reference to the right namespace.
I'm not sure how that addresses the issue of preserving case, if that
is desirable. If the key is "Rip van Winkle", then proper-casing it as
"Rip Van Winkle" is just as wrong as "rip van winkle" or "RIP VAN
WINKLE".
-- www.midnightbeach.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: usgog |
last post by:
I need to implement a function to return True/false whether String A
contains String B. For example, String A = "This is a test"; String B =
"is is". So it will return TRUE if String A includes two "i" and two
"s". The function should also handle if String A and B have huge
values, like two big dictionary.
What's the best approach to achieve this with the best performance?
what's the Big O then?
I am thinking to put A and B into two...
|
by: Alex |
last post by:
How in C#?
|
by: Dan V. |
last post by:
I would like to create a 2D string list (2D ArrayList ???). I would like to
pass in a table or query as a parameter and have both columns transform into
a 2D ArrayList. When I sort the one 'column' in the ArrayList, the other is
automatically sorted and so I can use IndexOf without fear. This is because
I will be going through 20,000 some odd records and don't want to use a
Lookup type of table/query; I figure an ArrayList.IndexOf method...
|
by: Doug |
last post by:
I have data that looks something like this when returned from a stored
procedure (3 columns, X rows):
Key1 Name1 Value1
Key1 Name2 Value2
Key1 Name3 Value3
Key1 Name4 Value4
Key2 Name1 Value1
Key2 Name2 Value2
Key3 Name1 Value1
|
by: Daniel |
last post by:
how to make two references to one string that stay refered to the same
string reguardless of the changing value in the string?
| |
by: ad |
last post by:
I have a string like
string myString="dog,cat,dog,tiger"
I want to delete the duplication part, and make myString to "dog,cat,tiger"
How can I do that?
|
by: ksrajalakshmi |
last post by:
Hai ,
in a textbox am having text as
"(20/100)+pay1*pay2" .it's a formula. and stored in a particular
variable.
string strformula="(20/100)+pay1*pay2" ;
i've to substitute the value of the variable 'pay1' & 'pay2' and
finding the value of that strformula.
can any onr tell me how to find 'pay1' and 'pay2' in the variable
|
by: chrisben |
last post by:
Hi,
Here is the scenario. I have a list of IDs and there are multiple threads
trying to add/remove/read from this list. I can do in C#
1. create Hashtable hList = Hashtable.Synchronized(new Hashtable());
2. create ArrayList aList = ArrayList.Synchronized(new ArrayList());
3. create a string sList = "";
For 1 and 2, since the list is synced, many threads can directly
|
by: Ashish Khandelwal |
last post by:
As MSDN is not giving us guarantee upon uniqueness of Hash Code, so
could any one suggest me that how to generate a unique Hash Code for
same string always, and generate different-2 Hash Code Different-2
string.
|
by: Ashish Khandelwal |
last post by:
-----See below code,
string str = "blair";
string strValue = "ABC";
string str1 = "brainlessness";
string strValue1 = "XYZ";
int hash = str.GetHashCode() ; // Returns 175803953
int hash1 = str1.GetHashCode(); // Returns 175803953
Hashtable ht = new Hashtable();
ht.Add(hash ,strValue);
ht.Add(hash1,strValue1); // ****ERROR****
|
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: 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: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |