code_junkie

Why Dictionary is preferred over hashtable in C#?

Nov 12th, 2011
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. var customers = new Dictionary<string, Customer>();
  2. ...
  3. Customer customer = customers["Ali G"];
  4.  
  5. var customers = new Hashtable();
  6. ...
  7. Customer customer = customers["Ali G"] as Customer;
  8.  
  9. [Serializable, ComVisible(true)]
  10. public abstract class DictionaryBase : IDictionary, ICollection, IEnumerable
  11. {
  12. // Fields
  13. private Hashtable hashtable;
  14.  
  15. // Methods
  16. protected DictionaryBase();
  17. public void Clear();
  18. .
  19. .
  20. .
  21. }
  22. Take note of these lines
  23. // Fields
  24. private Hashtable hashtable;
Add Comment
Please, Sign In to add comment