Указатель (массив целых) от C ++ до C# - PullRequest
0 голосов
/ 30 апреля 2020

Я пытаюсь работать с классом C ++ в c#. У меня трудности с хранением массива от cpp до c#.

C# Код:

 unsafe
       {
            fixed (int* pmyArray = &myArray[0])
            {
                CppWrapper.CppWrapperClass controlCpp = new CppWrapper.CppWrapperClass(pmyArray, noElements);
                controlCpp.fun(pmyArray, noElements);
                updatedArray = controlCpp.arr;
            }
        }

Cpp Библиотека классов Wrapper:

namespace CppWrapper {
public ref class CppWrapperClass
{
public:
    CppWrapperClass(int* pInt, int arraySize);
    vector<int> fun(int *pInt, int arraySize);
    vector<int> arr;

private:
    computingClass* pCC; //Pointer to class
};

Это, очевидно, приводит к ошибке a member of a managed class cannot be of a non-managed class type из-за несоответствия в данных типы. CppWrapperClass.fun(?, ?, ?)' is not supported by the language

Есть ли другой способ использовать массив cpp в качестве массива C#?

...