I have to send a list from C# to C++.The C# list is List<string>MyList and the C++ code accepts it as list<wstring>cppList.How to use marshalas for this.
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It is always wiser not to use complex type marshaling between native code and managed code.
In case of
List, these type totally differ from each other as they have different memory layout for each item.So the best way is to write a utility function in a native dll that accepts array of string(char*) and manually build your native
Listand ultimately call the desired method. It is easy for your to create wrapper of that utility function.