C# Crawler
Sagiv Hadaya is crawling in C#...just for fun





Subscribe to "C# Crawler" in Radio UserLand.

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.

Google


Wednesday, September 04, 2002
 
Hashtable: add versus property

In my last Hashtable & serialization example, you my have noticed a Hashtable addition that has a different approach then the retrival.

for addition we used: myCollection.add(mn,ad);

for retrival we used: ad = myCollection[mn];

where myCollection is the hashtable, mn and ad are structs.

i got an email saying that an addition could be performed as such: myCollection[mn]=ad;  and that is correct and excellent, but lets point the differences between property addition and add method:

While using a property addition (eg myCollection[mn]=ad;) we can add new items, However, if the specified key already exists in the Hashtable, setting the Item property overwrites the old value. In contrast, the Add method does not modify existing elements, and if the item exists, an exception is thrown.

hope that clears things up.


12:04:11 PM    



Click here to visit the Radio UserLand website. © Copyright 2002 Sagiv Hadaya.
Last update: 10/10/2002; 1:16:48 AM.
September 2002
Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30          
Aug   Oct

C#_Help

C#_Organization

DEVX

Google

Microsoft

CSharp_Friends

C_Sharp_Center