public void Insert(string name, int phoneNumber) { int hashCode = PreHash(name); int hashPosition = EncryptHash(hashCode); Console.WriteLine("Insert to position: " + hashPosition); arr[hashPosition] = new PhoneBookData { name = name, number = phoneNumber }; }
public static void Main(string[] args) { PhoneBook phoneBook = new PhoneBook(); phoneBook.Insert("Ruan Xun", 123456); phoneBook.Insert("Liu Yongchen", 654321); PhoneBookData ruanxun = phoneBook.Search("Ruan Xun"); PhoneBookData liuyongchen = phoneBook.Search("Liu Yongchen"); Console.WriteLine(ruanxun.name + ": " + ruanxun.number); Console.WriteLine(liuyongchen.name + ": " + liuyongchen.number); }