Я получил ответ как передать массив из C# в C ++ с помощью swig. См. Ниже
'' 'Код интерфейса SWIG
%module (directors="1") CppTestApp
%{
#include "TestClass.h"
#include "TestDataClass.h"
%}
%include <windows.i>
%include <std_string.i>
%include <arrays_csharp.i>
CSHARP_ARRAYS(char *, string)
%typemap(imtype, inattributes="[In, global::System.Runtime.InteropServices.MarshalAs(UnmanagedType.LPArray, SizeParamIndex=0, ArraySubType=UnmanagedType.LPStr)]") char * INPUT[] "string[]"
%apply char * INPUT[] { char * argv [], char * argvqq [] }
%apply int INPUT[] { int sourceArray [] }
%apply double INPUT[] { double sourcedoubleArray [] }
%apply char INPUT[] { char chArray [] }
%apply bool INPUT[] { bool bArray [] }
%apply long INPUT[] { long lArray [] }
%apply float INPUT[] { float fArray [] }
%feature("director") Base;
%include "TestClass.h"
%include "TestDataClass.h"
' ''
'' 'Код C ++
class TestClass
{
public:
int times2(int sourceArray[], double sourcedoubleArray[], char* argv[], char chArray[], bool bArray[], float fArray[], long lArray[]);
};
' ' '
' '' Сгенерированный SWIG C# код
[global::System.Runtime.InteropServices.DllImport("CppTestApp", EntryPoint="CSharp_TestClass_times2")]
public static extern int TestClass_times2(global::System.Runtime.InteropServices.HandleRef jarg1, [global::System.Runtime.InteropServices.In, global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPArray)]int[] jarg2, [global::System.Runtime.InteropServices.In, global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPArray)]double[] jarg3, [In, global::System.Runtime.InteropServices.MarshalAs(UnmanagedType.LPArray, SizeParamIndex=0, ArraySubType=UnmanagedType.LPStr)]string[] jarg4, string jarg5, [global::System.Runtime.InteropServices.In, global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPArray,ArraySubType=System.Runtime.InteropServices.UnmanagedType.I1)]bool[] jarg6, [global::System.Runtime.InteropServices.In, global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPArray)]float[] jarg7, [global::System.Runtime.InteropServices.In, global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPArray)]int[] jarg8);
'' '