upup upup

upup upup

  • NA
  • 1
  • 4.9k

Multiple values in hashtable (C#)

Dec 4 2011 1:07 AM
How can I make a hashTable with three parameters? I want to store phone numbers, names and addresses using a hashTable. Phone number as the key, and the name, address as its value. But I can put two data only, phone number and name. How do I get to save a phone number, name, address in the hashTable?

Hashtable phoneBook;   public FrmPhoneBook() { InitializeComponent(); phoneBook = new Hashtable(); }   public void addNewPhoneBook(string name, string tel, string add) { string names = name; string telp = tel; string address = add;   if (!phoneBook.ContainsKey(telp)) { phoneBook.Add(telp, names); getDetails(); } }   public void getDetails() { lvDetails.Items.Clear(); foreach (DictionaryEntry values in phoneBook) { lvDetails.Items.Add(values.Value.ToString()); lvDetails.Items[lvDetails.Items.Count - 1].SubItems.Add( values.Key.ToString()); } }

Answers (2)