Skip to Main Content
C# 10.0 All-in-One For Dummies
book

C# 10.0 All-in-One For Dummies

by John Paul Mueller
March 2022
Intermediate to advanced content levelIntermediate to advanced
864 pages
19h 46m
English
For Dummies
Content preview from C# 10.0 All-in-One For Dummies

Chapter 10

Creating Lists of Items with Enumerations

IN THIS CHAPTER

Bullet Finding real-world examples of enumerations

Bullet Creating and using enumerations

Bullet Using enumerations to define flags

Bullet Using enumerations as parts of switches

To enumerate means to specify individual items, as in a list. For example, you might create an enumeration of colors and then list individual colors, such as red, blue, green, and so on. Using enumerations in programming makes sense because you can list individual items as part of a common collection. For example, Colors.Blue would indicate the color blue, and Colors.Red would indicate the color red. Because enumerations are so handy, you see them used all the time in the actual world, which is why you also see them in applications. Code should model the real world to provide useful functionality in an easy-to-understand form.

The enum keyword lets you create enumerations in C#. This chapter begins by discussing basic enum usage but then moves on to some interesting additions you can make. For example, you can use initializers to determine the initial value of each ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

C# Cookbook

C# Cookbook

Joe Mayo
Head First C#, 4th Edition

Head First C#, 4th Edition

Andrew Stellman, Jennifer Greene

Publisher Resources

ISBN: 9781119839071Purchase Link