How to deal with almost the same enums?

Posted by reza on Programmers See other posts from Programmers or by reza
Published on 2012-09-29T07:21:40Z Indexed on 2012/09/29 15:52 UTC
Read the original article Hit count: 294

Filed under:
|
|
|

I need to define enums in several classes. The majority of fields are the same in all of the enums. But one has one or two more fields, another has fewer fields. Now I wonder what is the best way to deal with this?

  1. Create separate enums

    public enum Foo {field1, field2, field5 };
    public enum Bar {field1, field2, field3, field4 };
    
  2. or use a general enum for them all

    public enum FooBar {field1, field2, field3, field4 , field5};
    

The enumerations contain the list of actions available for each class.

© Programmers or respective owner

Related posts about c#

Related posts about refactoring