c# - 如何将带有枚举的 VB.net 接口(interface)转换为 C#

标签 c# vb.net interface enums

我有以下需要移植到 C# 的 VB.net 接口(interface)。 C# 不允许在接口(interface)中使用枚举。如何在不更改使用此接口(interface)的代码的情况下移植它?

Public Interface MyInterface

    Enum MyEnum
        Yes = 0
        No = 1
        Maybe = 2
    End Enum

    ReadOnly Property Number() As MyEnum

End Interface

最佳答案

public enum MyEnum
{
    Yes = 0,
    No = 1,
    Maybe = 2
}

public interface IMyInterface
{
    MyEnum Number { get; }
}

关于c# - 如何将带有枚举的 VB.net 接口(interface)转换为 C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/178561/

相关文章:

c# - 当 ListView 中的数据更改时,WPF 获取 "old"值

C# PInvoking user32.dll 在 64 位系统上

java - Annotation 可以实现接口(interface)吗?

Java反射: how to call a method with private interface as argument?

oop - 实现接口(interface)的缺点

javascript - 在 ASP.NET MVC C# 中将 if 和 else 放入 Foreach 循环中

c# - 在 C# 中声明和使用匿名对象数组

.net - 为什么 IEnumerable 的这个 ToArray() 扩展方法会抛出 ArrayTypeMismatchException?

vb.net - 检测互联网是否已连接

c# - 在 .Net 中获取 CryptoStream 的长度