O'Reilly logo

Expert C# 5.0: with the .NET 4.5 Framework by Mohammad Rahman

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

CHAPTER 6

images

Enum

This chapter will discuss one of the nice features of the C# language: enumerated type or enum for short. I will show you how the enum type is defined in the .NET Framework, how you can get symbolic names and values from the enum, and how enum parses in C#.

Enum and .NET

Enum in C# is a type, which is a set of symbolic names and values (given by you or the C# compiler) pair. For example:

public enum Planets {     Sun = 0,     Earth, }

Or with the explicit type:

public enum Planets : int        /* int is the underlying type which C# compiler will use to set                                   * the values */ {                                 ...

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