0

Let consider I have two enums A and B -

enum A { a1, a2, a3, a4, a5, a6 }

enum B { b1, b2, b3 }

I have a function which uses these enums. I want to assign these enums in a new enum on the basis of the conditional logic.

public void UseEnum()
{
    enum c;

    if (true)
    {
       c = enumA
    }
    else
    {
       c = enumB
    }

    UseEnumC(c.enumvalue);
}

I want to use this new enum values in this function useEnumC.

  • 2
    what is the signature of the `UseEnumC` method? What do you plan to do with `c` afterwards? – Cristian Lupascu Aug 01 '13 at 14:29
  • AFAIK you can't do polymorphic / inheritance with enums. For alternative patterns, look here http://stackoverflow.com/questions/757684/enum-inheritance – StuartLC Aug 01 '13 at 14:32
  • Think I misunderstood the question, are you just trying to take a reference to an enum and pass it as a parameter? – James Aug 01 '13 at 14:39
  • yes James. I want to use this new enum values in this function. – Sanjay Gupta Aug 01 '13 at 14:54
  • It is not clear what you want to do. `enum c;` is not a correct syntax. Can you show implementation of `UseEnumC()` ? – YK1 Aug 01 '13 at 16:41

0 Answers0