Question

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.

Update : sorry if the question was not clear enough . I want to use these enums as parameters in classes methods . for example classOne has a method as below :

public void DoSomeThing(Foo action,object moreData)
{
    // operation desired
}

here I want action to be limited to Insert , Update and Delete

while in classTwo :

public void DoSomeThingElse(Foo action)
{
    // operation desired
}

I want to limit action availabe to Insert and Select

No correct solution

Licensed under: CC-BY-SA with attribution
scroll top