Storing a value using the enum keyword

Sometimes, a value needs to be one of a limited list of options. For example, a person may have a favorite ancient world wonder. Sometimes, a value needs to be a combination of a limited list of options. For example, a person may have a bucket list of ancient world wonders they want to visit. We can store this data using an enum type.

An enum type is a very efficient way of storing one or more choices because, internally, it uses the int values in combination with a lookup table of string descriptions.

In Visual Studio 2017, add a new class to the PacktLibrary project named WondersOfTheAncientWorld by pressing Shift + Alt + C or going to Project | Add Class....

In Visual Studio Code, add a new class ...

Get C# 7.1 and .NET Core 2.0 – Modern Cross-Platform Development - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.