使实现枚举的类成为必需 [英] make necessitate a class for implement an enum
本文介绍了使实现枚举的类成为必需的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我需要使用于实现enum
类型的类成为必需,该怎么办?
我也尝试了一个抽象类和interfac,但是它有错误
Hello everybody,
I need to make necessitate a class for implement an enum
type, what should I do?
I also tried an abstract class and interfac, but its has error
public abstract class AbstractUserControl
{
// Error: The modifier 'abstract' is not valid for this item
public abstract enum MyEnum
{
}
public abstract UserControl GetUserControl();
public abstract void Disposing();
}
interface IUserControlFactory
{
//Error: 'MyEnum': interfaces cannot declare types
enum MyEnum
{
}
}
任何HLP都......
预先谢谢您.
Any hlp pls...
Thank you in advance.
推荐答案
看看下面类似的问答"讨论.
接口/基类中的C#枚举?
如何在其中创建抽象枚举NET类库?
Have a look at similar Question-Answer discussions below.
C# enum in interface/base class?
How can I make an abstract enum in a .NET class library?
接口只能包含方法,委托,事件或索引器的签名.您不能在接口中声明枚举或任何其他类型-您必须在接口外部进行声明.恐怕这就是语言定义!
MDSN接口 [
An interface can only contain the signatures of methods, delegates, events or indexers. You cannot declare an enum or any other type in an interface - you have to make the declaration outside the interface. That is the language definition I''m afraid!
MDSN interface[^]
您应该将枚举放在界面之外.
You should put your enum outside the interface.
interface IUserControlFactory
{
}
enum MyEnum
{
}
请参阅下面的链接,
http://social.msdn.microsoft.com/论坛/en-US/csharpgeneral/thread/14beb8d1-63d9-42f7-b036-eb9ebb106d08 [
Refer link below,
http://social.msdn.microsoft.com/forums/en-US/csharpgeneral/thread/14beb8d1-63d9-42f7-b036-eb9ebb106d08[^]
这篇关于使实现枚举的类成为必需的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文