2
Answers

Multiple values in hashtable (C#)

upup upup

upup upup

13y
3.8k
1
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)
Next Recommended Forum