C++/CLR int to System::String^

Summary

In C++/CLR development, converting between native integer types and the managed System::String^ type is a common task. To convert a System::String^ to an int, developers can utilize the static int::Parse() method, passing the string as an argument. Conversely, transforming an int into a System::String^ is straightforward by calling the ToString() method directly on the integer variable. These conversion patterns are generally applicable across various other data types within the C++/CLR environment.

In C++/CLR (for Microsoft), sometimes we need to convert int to System::String type or vice versa. The simple way is :

From System::String^ to int
Sign In to Vote

int num= int::Parse(str); // System::String^ to int

From int to System::String^

System::String^ str = num.ToString(); // int to System::String^

For all the other data types, similar ways can be adopted.


MICROSOFT C++ CLR SYSTEM::STRING CONVERT INT

  RELATED

  COMMENTS

2
sonic
Feb 8, 2012 at 9:51 am
This is exactly what I want
Anonymous
Aug 8, 2019 at 4:39 am

Thanks a lot!