Ch.5, Hashtable code mystery
I can't find any reason why on page 162 the EmailHashtable() property is added. What is the purpose of it? Why is it Public?
I removed this entire property code and replaced all instances of "EmailHashtable" in the code with "objEmailHashtable". The code works perfectly fine, the same as with this property. So the question again - why add this property and not use the object directly?...
Another question: on page 166 we add new definition of RemoveAt method. What for?... We don't use RemoveAt in the code anywhere in this Chapter. Is it done "just in case", to make the code more flexible? Deleting the RemoveAt definition didn't change anything in the way the sample code worked - it was still working fine.
In "How it works" there is a text: "Youâll also find that when you delete items from the collection by using Remove, the corresponding entry is also removed from the Hashtable, because of this method that you added:". It doesn't make sense to me as the method shown below is the one for RemoveAt. So maybe it is an error and the text should be "also find that when you delete items from the collection by using RemoveAt, the corresponding entry is also removed from the Hashtable, because of this method that you added:" - that would confirm that the new RemoveAt method is added just to make the code more universal, not specifically for the code written in this chapter as it doesn't use it.
|