你怎么转换系统::字符串到std :: string的在C ++ .NET?
How do you convert System::String to std::string in C++ .NET?
有更清晰的语法,如果你使用的是最新版本的.NET
There is cleaner syntax if you're using a recent version of .net
#include "stdafx.h"
#include <string>
#include <msclrmarshal_cppstd.h>
using namespace System;
int main(array<System::String ^> ^args)
{
System::String^ managedString = "test";
msclr::interop::marshal_context context;
std::string standardString = context.marshal_as<std::string>(managedString);
return 0;
}
这也为您提供了更好的清理工作异常的脸。
This also gives you better clean-up in the face of exceptions.
有一个 MSDN文章各种其他转换