Calling C++ function from C#
问题 I have a the following C++ function void FillAndReturnString(char ** someString) { char sourceString[] = "test"; *someString = new char[5]; memcpy(*someString, sourceString, 5); } It is declared as extern "C" { __declspec(dllexport) void __cdecl FillAndReturnString(char ** someString); } How do I call this function from C#? Thanks 回答1: With P/Invoke. 回答2: You need to know that you're allocating unmanaged memory block in your c++ function, so it will not be possible to pass a managed String or