我有一个C#的dll,它返回一个类对象。
DLL代码:
Person.cs:
我是一个有用的助手,可以翻译文本。
在此之后,当我编译“RunApp”代码时,出现错误:
DLL代码:
Person.cs:
namespace Extract
{
public class Person
{
public string name;
public string address;
public int age;
public int salary;
}
}
Class1.cs
namespace Extract
{
public class MClass
{
public static Person GetPerson()
{
Person p = new Person();
p.name = "Deepak";
p.address = "Bangalore";
p.age = 30;
p.salary = 20000;
return p;
}
}
}
我是一个有用的助手,可以翻译文本。
我在C#中有另一个程序"RunApp",它具有相同的Person.cs类,并尝试从上述dll获取对象。
RunApp代码:
Person.cs:
namespace Extract
{
public class Person
{
public string name;
public string address;
public int age;
public int salary;
}
}
Form1.cs:
namespace Ex
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Person mem = MClass.GetPerson();
}
}
}
在此之后,当我编译“RunApp”代码时,出现错误:
"无法隐式转换类型 'Extract.Person' 为 'Ex.Person'"。我尝试将“RunApp”代码的命名空间从“Ex”更改为“Extract”,但仍然出现相同的错误:“无法隐式转换类型 'Extract.Person' 为 'Extract.Person' "。
我想要从Extract.dll向RunApp程序发送值。我希望在多个程序中使用这个dll。
请问有人能帮忙解决这个问题吗?
{get;set;}
。 - Marc Gravell