O'Reilly logo

C# Data Structures and Algorithms by Marcin Jamro

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Example – phone book

As an example, you will create an application for a phone book. The Hashtable class will be used to store entries where the person name is a key and the phone number is a value, as shown in the following diagram:

The program will demonstrate how to add elements to the collection, check the number of stored items, iterate through all of them, check whether an element with a given key exists, as well as how to get a value based on the key.

The whole code presented here should be placed in the body of the Main method in the Program class. At the beginning, let's create a new instance of the Hashtable class, as well as initialize ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required