Reputation: 13195
I have a standard library string, and I would like to make the following conversion:
System::String^ to std::string
Upvotes: 0
Views: 888
Reputation: 3559
Code fragment to convert std::string
to System::String^
:
#include <msclr/marshal.h>
std::string str = "Hello World";
System::String^ result = msclr::interop::marshal_as<System::String^>(str.c_str());
Code fragment to convert System::String^
to std::string
:
#include <msclr/marshal.h>
System::String^ str = "Hello World";
std::string result = msclr::interop::marshal_as<std::string>(str);
Upvotes: 2