From managed C++, I am calling an unmanaged C++ method which returns a double. How can I convert this double into a managed string?
Asked
Active
Viewed 3,055 times
2 Answers
7
I assume something like
(gcnew System::Double(d))->ToString()

Micha Wiedenmann
- 19,979
- 21
- 92
- 137

DrPizza
- 17,882
- 7
- 41
- 53
-
Short and concised, thanks! Note: It should be (gcnew System::Double(d))->ToString() instead, but close enough. – stung Sep 19 '08 at 19:10
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);

Scott Nichols
- 6,108
- 4
- 28
- 23