gpt4 book ai didi

string - C++/CLI 从 System::String^ 转换为 std::string

转载 作者:行者123 更新时间:2023-12-03 05:03:26 25 4
gpt4 key购买 nike

有人可以发布一个可以转换的简单代码吗,

System::String^

至,

C++ std::string

也就是说,我只想分配值,

String^ originalString;

至,

std::string newString;

最佳答案

不要自己动手,使用these Microsoft 提供的方便(且可扩展)的包装器。

例如:

#include <msclr\marshal_cppstd.h>

System::String^ managed = "test";
std::string unmanaged = msclr::interop::marshal_as<std::string>(managed);

关于string - C++/CLI 从 System::String^ 转换为 std::string,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/946813/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com