c#中的抽象枚举 [英] Abstract enum in c#
本文介绍了c#中的抽象枚举的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法在 C# 中创建一个 (protected
) enum
abstract
?
基类示例:
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屋!
查看全文