【发布时间】:2011-01-05 11:51:07
【问题描述】:
我有以下代码:
public int Method(MyEnum myEnum)
{
switch (myEnum)
{
case MyEnum.Value1: return 1;
case MyEnum.Value2: return 2;
case MyEnum.Value3: return 3;
}
}
public enum MyEnum
{
Value1,
Value2,
Value3
}
我得到了错误:"Not all code paths return a value"。我不明白switch 语句怎么不能跳转到指定的情况之一。
enum 可以以某种方式成为null 吗?
【问题讨论】:
标签: c# .net visual-studio-2008 c#-3.0 enums