在运行时分配枚举

时间:2013-08-01 14:24:54

标签: c#-4.0 enums

考虑我有两个枚举A和B -

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

enum B { b1, b2, b3 }

我有一个使用这些枚举的功能。我想根据条件逻辑在新的枚举中分配这些枚举。

public void UseEnum()
{
    enum c;

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

    UseEnumC(c.enumvalue);
}

我想在这个函数useEnumC中使用这个新的枚举值。

0 个答案:

没有答案