How to convert a unmanaged double to a managed string?

假装没事ソ 提交于 2019-12-10 21:57:11

问题


From managed C++, I am calling an unmanaged C++ method which returns a double. How can I convert this double into a managed string?


回答1:


I assume something like

(gcnew System::Double(d))->ToString()



回答2:


C++ is definitely not my strongest skillset. Misread the question, but this should convert to a std::string, not exactly what you are looking for though, but leaving it since it was the original post....

double d = 123.45;
std::ostringstream oss;
oss << d;
std::string s = oss.str();

This should convert to a managed string however..

double d = 123.45
String^ s = System::Convert::ToString(d);


来源:https://stackoverflow.com/questions/103298/how-to-convert-a-unmanaged-double-to-a-managed-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!