My C++ DLL have a function like this:
void func1(int& count, int* pValue);
this function will determine the "count", and put some values into the pValue int array which is the length of "count".
how can I define my C# code? you 开发者_StackOverflowcan ignor the [DllImport ...] part.
thanks,
By ref &
isn't going to happen as far as I've worked out.
MSDN has the answers you seek
and don't forget to export your function from C++ as extern "C"
According to MSDN: Default marshaling for arrays on the C# side I think you want something like the following
public static extern void func1(
out int count,
[MarshalAs(UnmanagedType.LPArray, SizeParamIndex=0)] int[] values );
Where SizeParamIndex
tells .net which argument will hold the size of the array to be marshaled.
精彩评论