【发布时间】:2013-09-19 12:19:18
【问题描述】:
我有 1. 声明接口(InterfaceCLI)和实现值类型(PointD)的CLI库 2. 带有实现 1 接口的类 (PointD) 的 C# 库
问题是 C# 上奇怪的接口实现。它需要这样的代码 公共值类型 GetPoint() 而不是 public PointD GetPoint()
示例代码 CLI:
public value struct PointD
//public ref class PointD
{
public:
PointD(double x, double y);
// Some stuff
};
public interface class InterfaceCLI
{
public:
double Foo();
PointD^ GetPoint();
};
示例代码 C#:
public class Class1 : InterfaceCLI
{
public double Foo()
{
PointD x=new PointD( 1.0 , 2.7 );
return x.Y;
}
public ValueType GetPoint()
{
throw new NotImplementedException();
}
/*
public PointD GetPoint()
{
throw new NotImplementedException();
}
*/
}
为什么在 Class1 类中需要 ValueType 而不是 PointD?!
【问题讨论】:
标签: c# interface c++-cli value-type