#462 – Duplicate Enumerators in an Enumerated Type

When defining a new enumerated type, you can define multiple enumerators that have the same underlying value.  You might do this when you have a finite set of enumerated values and you want to map them to a smaller finite set of internal values.

In the example below, we have six different MovieRatings values, internally.  But we define 10 different enumerators for the type, so some of them end up mapping to the same value.

        public enum MovieRatings
        {
            DidntSeeIt = 0,
            NONE = 0,
            Crappy = 1,
            Horrible = 1,
            Watchable = 2,
            Average = 3,
            Good = 4,
            SeeIt = 4,
            Great = 5,
            MustSee = 5
        };
Advertisements

About Sean
Software developer in the Twin Cities area, passionate about .NET technologies. Equally passionate about my own personal projects related to family history and preservation of family stories and photos.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: