如何将对象数组从unManaged C ++传递给manged C#

如何将对象数组从unManaged C ++传递给manged C#

问题描述:

我的数据是在unManaged C ++中生成的,我将数据填充到一个对象中,该对象是我在Managed C ++包装器中处理的对象。如何传递该对象并访问该对象内的数据。



之前我发送了一个Integer数组并用于以托管形式将其转换为,



cli :: array< System :: Int> ^ newIndices = gcnew cli :: array< System :: Int32>(num);



如何对象数组做同样的事情?

我使用的是CLI包装器而不是COM接口。

My data is generated in unManaged C++, I am filling the data into a object that object that object i am processing in Managed C++ wrapper. how to pass that object and access data inside that object.

Earlier i was sending Array of Integer and used to convert it in managed form as,

cli::array<System::Int>^ newIndices =gcnew cli::array <System::Int32>(num);

how to do the same with object array ?
I am using CLI wrapper and not the COM interface.

您应该保持大多数原生数据格式,即int。看看我是如何在我的文章中完成的。



基本原则是用目标语言将数据复制到自己的内存/对象中。
You should stay in a mostly native data format ie int. Take a look how I done it in my article.

The fundamental principle is to copy the data in own memory/objects in the target language.