.net - 一个接口(interface)可以包含一个 ENum 吗?

标签 .net asp.net vb.net interface

接口(interface)可以包含枚举吗?

我正在使用 asp.net 2.0。当我向下面的接口(interface)添加枚举时,我的代码突然开始出现问题。其中,LookUpType 是一个枚举。

Public Interface ILookup
    Property ID() As Int32
    Property Text() As String
    Property Description() As String
    Property Status() As Status
    Property OrderID() As Int32
    ReadOnly Property LookUpType() As LookUpType
End Interface

最佳答案

你的问题有点模棱两可,听起来你可能会问以下任何一个

接口(interface)可以返回枚举类型吗?

是的。枚举在任何方面都没有特殊之处,无法阻止它们成为接口(interface)上的返回类型

接口(interface)可以包含枚举定义吗?

是的,这在 VB.Net 中是完全合法的。但是在 C# 中是不合法的

Interface IFoo
    Enum E1
        V1
    End Enum
    Function SomeMethod() As E1
End Interface

关于.net - 一个接口(interface)可以包含一个 ENum 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2148336/

相关文章:

ios - AFNetworking 2.0,SOAP 网络服务 : how to make request?

c# - 在命令行上告诉 OwinHost 如何在项目外部使用 cwd 加载 OwinSetup 类

c# - 如何显示 2011 年 11 月 16 日的日期时间 15 :12 format

c# - 阻止从同一用户 ID 到 Web 方法的多个请求 C#

vb.net - 在vb.net中将字符串格式设置为美国电话号码

c# - 获取字典中的最后一个元素?

c# - 为什么我的证书没有得到验证?

.net - 事件验证 : Allow __doPostBack for one control and *any* arguments

asp.net - 从日期时间减去 1 年

vb.net - 如何让一个线程等到另一个线程完成?