这样做没有数据丢失,那么为什么必须明确地将枚举转换为整数?
如果它是隐含的,那么它是不是更直观,比如当你有更高级别的方法时:
PerformOperation ( OperationType.Silent type )
Run Code Online (Sandbox Code Playgroud)
在哪里PerformOperation调用一个被暴露的包装C++方法:
_unmanaged_perform_operation ( int operation_type )
Run Code Online (Sandbox Code Playgroud) 假设有
enum SomeEnum { One, Two, Three };
Run Code Online (Sandbox Code Playgroud)
SomeEnum是一个枚举,所以它应该从Enum继承,所以如果我写:
Dictionary<Enum, SomeClass> aDictionary = new Dictionary<SomeEnum, SomeClass>();
Run Code Online (Sandbox Code Playgroud)
编译器抱怨它不能隐式地将SomeEnum转换为Enum?