在 C++/CLI 中实现 C# 接口函数返回数组

Implement C# interface function returning array, in C++/CLI

我有一个引用 C# dll 的 C++/CLI 项目,我需要实现一个接口 class。

C# 中的接口 class 如下所示:

public interface IMeshData{
    //(...)        
    INode NodeById(int nodeId);
    double[] NodeXYZById(int nodeId);
}

在C++项目中我可以实现这个接口:

public ref class IMeshData_class : public IMeshData{

public:
    //this one is accepted:
    virtual INode^ NodeById(int nid){
        return this->NodeById(nid);
    }
    //this one gives me an error:
    virtual double*  NodeXYZById(int nid){
         return this->NodeXYZById(nid);
    }
}

当我第一次在没有任何成员函数的情况下定义上面的 class 时,出现错误:

Error: class fails to implement interface member function "IMeshData::NodeById" (declared in (...).dll)

所以在定义函数 NodeById 之后,这个错误消失了,我得到:

Error: class fails to implement interface member function "IMeshData::NodeXYZById" (declared in (...).dll)

NodeXYZById return a double[],我认为这会在 C++ 中 翻译 double*,但它不会好像不是这样。

我应该如何在 C++ 中正确实现 return 数组的 C# 成员函数?

如上所述,在 C++/CLI 中,您必须使用类型 array<T>^ 代替 C# 中的 T[]