我想声明一个新的枚举与非默认的基础类型。这工作:为什么枚举声明接受短但不是Int16
public enum MyEnum : short
{ A, B, C, }
但我不明白为什么这个不能编译的原因:
public enum MyEnum : System.Int16
{ A, B, C, }
编译器说
类型字节,为sbyte,短,USHORT,INT , uint,long or ulong expected
据我所知,是Int16在所有.NET版本(包括32/64位风格)上的别名。我不明白为什么编译器给这个特殊情况下的别名赋予不同的含义。
任何解释?
我记得有一个类似的问题越来越关闭昨天 – V4Vendetta 2011-06-01 09:57:31
我发现两个使用谷歌几乎相同的问题:http://stackoverflow.com/questions/3774650/enum-members-of-int32-type和http://stackoverflow.com/questions/1813408/c-int-int32 -and-枚举。 – 2011-06-01 10:00:01
尽管花了几分钟的时间阅读搜索结果,但我没有找到它:) – 2011-06-01 10:00:32