c#中的抽象枚举 [英] Abstract enum in c#
本文介绍了c#中的抽象枚举的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法让(受保护的
) enum
abstract
在C#中?
基类示例:
Is there a way to make a (protected
) enum
abstract
in C#?
Example of base class:
protected abstract enum commands{}; //CS0106
protected abstract void useCommands(commands meh);
这不能编译,因为 abstract
对于此项目无效。
是否有一种工作方式可以实现所需的行为?
This does not compile, since "abstract
is not valid for this item".
Is there a working way to achive the desired behaviour?
推荐答案
- 所有枚举必须来自
System.Enum
- 所有枚举都是值类型,因此是密封的。
由于上述这两条规则,无法继承枚举。
Because of above these two rules, you cannot inherit enums.
这篇关于c#中的抽象枚举的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文