使实现枚举的类成为必需

编程入门 行业动态 更新时间:2024-10-28 11:29:40
本文介绍了使实现枚举的类成为必需的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好, 我需要使用于实现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 { }

请参阅下面的链接, social.msdn.microsoft/论坛/en-US/csharpgeneral/thread/14beb8d1-63d9-42f7-b036-eb9ebb106d08 [ ^ ]

Refer link below, social.msdn.microsoft/forums/en-US/csharpgeneral/thread/14beb8d1-63d9-42f7-b036-eb9ebb106d08[^]

更多推荐

使实现枚举的类成为必需

本文发布于:2023-11-15 22:04:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1598357.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!