3

Possible Duplicate:
C++/CLI Converting from System::String^ to std::string

I am using a C# DLL in my C++ code (Visual Studio 2010). How do I convert a System::String^ to a C++ std::string?

0

1 Answer 1

0

System.Runtime.InteropServices.Marshal has several methods that convert a string to an array of characters, which you could then use any manner of methods to get a std::string.

I believe the recommendation is to use StringToBSTR eventually calling FreeBSTR once you have copied the data to a different object.

The question I linked to as a comment recommends StringToCoTaskMemUni.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.