Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert a unmanaged double to a managed string?

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

like image 549
stung Avatar asked Nov 18 '25 21:11

stung


2 Answers

I assume something like

(gcnew System::Double(d))->ToString()
like image 85
DrPizza Avatar answered Nov 20 '25 12:11

DrPizza


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);
like image 20
Scott Nichols Avatar answered Nov 20 '25 12:11

Scott Nichols



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!