1. 宣言されたインターフェイス ( InterfaceCLI ) と実装された値型 ( PointD ) を持つ CLI ライブラリ 2. 1 からインターフェイスを実装するクラス ( PointD ) を持つ C# ライブラリ
問題は、C# での奇妙なインターフェイスの実装です。public PointD GetPoint() の代わりに、このようなコード public ValueType 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 で PointD ではなく ValueType が必要なのはなぜですか?!