界面内的类在visual studio中产生错误 [英] Class inside an interface producing errors in visual studio

查看:81
本文介绍了界面内的类在visual studio中产生错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨在界面中有几个类但是当它构建时我得到一个错误,接口不能声明类型...代码类似于下面

Hi Have several classes inside an interface but when it builds I get an error that Interfaces cannot declare types...code is similar to below

public interface Interface1{
    int Value;
     public class Class1{
           public string MyValue { get; set; }
     }
}





这个最初用VB.Net编写并反编译..原来的dll运行很好。

我将代码整合到重构的C#项目中并得到错误。



我意识到你不能定义对象在一个界面但我相信你可以在一个合并的班级?



无论如何要绕过这个?



我尝试了什么:



尝试删除课堂上的所有类型但没有好



This was originally written in VB.Net and decompiled..the original dll runs fine.
I am incorporating the code in a refactored C# project and get the error.

I realize you can't have defined objects in an interface but I believe you can in an incorporated class??

Anyway to get around this?

What I have tried:

tried removing all types in class but no good

推荐答案

您可以在VB中定义接口中的类,但不能在C#中 - 您将始终收到错误

You can define a class within an Interface in VB, but you can't in C# - you will always get the error
'ClassName': interfaces cannot declare types



你必须直接使用VB代码,或者重新设计以解决这个问题。


You will have to either use the VB code directly, or redesign to get round this.


这篇关于界面内的类在visual studio中产生错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆