Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 4.0 在运行时分配枚举 请考虑我有两个枚举A和B-< /P> enum A { a1, a2, a3, a4, a5, a6 } enum B { b1, b2, b3 }_C# 4.0_Enums - Fatal编程技术网

C# 4.0 在运行时分配枚举 请考虑我有两个枚举A和B-< /P> enum A { a1, a2, a3, a4, a5, a6 } enum B { b1, b2, b3 }

C# 4.0 在运行时分配枚举 请考虑我有两个枚举A和B-< /P> enum A { a1, a2, a3, a4, a5, a6 } enum B { b1, b2, b3 },c#-4.0,enums,C# 4.0,Enums,我有一个使用这些枚举的函数。我想根据条件逻辑在新的枚举中分配这些枚举 public void UseEnum() { enum c; if (true) { c = enumA } else { c = enumB } UseEnumC(c.enumvalue); } 我想在这个函数useEnumC中使用这个新的枚举值 UseEnumC方法的签名是什么?之后你打算用c做什么?好吧,你不能用枚举做多态

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

public void UseEnum()
{
    enum c;

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

    UseEnumC(c.enumvalue);
}

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

UseEnumC
方法的签名是什么?之后你打算用
c
做什么?好吧,你不能用枚举做多态/继承。对于其他模式,请看这里,我想我误解了这个问题,您是否只是尝试引用枚举并将其作为参数传递?是的,James。我想在此函数中使用此新枚举值。不清楚要执行什么操作<代码>枚举c不是正确的语法。您是否可以显示
UseEnumC()
的实现?