从 System::String^ 转换为 System::String
Convert from System::String^ to System::String
我有一个标准库字符串,我想进行如下转换:
System::String^ 到 std::string
将std::string
转换为System::String^
的代码片段:
#include <msclr/marshal.h>
std::string str = "Hello World";
System::String^ result = msclr::interop::marshal_as<System::String^>(str.c_str());
将System::String^
转换为std::string
的代码片段:
#include <msclr/marshal.h>
System::String^ str = "Hello World";
std::string result = msclr::interop::marshal_as<std::string>(str);
我有一个标准库字符串,我想进行如下转换:
System::String^ 到 std::string
将std::string
转换为System::String^
的代码片段:
#include <msclr/marshal.h>
std::string str = "Hello World";
System::String^ result = msclr::interop::marshal_as<System::String^>(str.c_str());
将System::String^
转换为std::string
的代码片段:
#include <msclr/marshal.h>
System::String^ str = "Hello World";
std::string result = msclr::interop::marshal_as<std::string>(str);