Question about String in mc++

  • Thread starter Thread starter Ereinion
  • Start date Start date
E

Ereinion

Hello. In C# you can do like this:
int a = 5, b = 10;
string s = "blabla bla" + a + "bla bla bla" + b + ".";

How do you do that in mc++?
 
Pent said:
String::Concat

a/b.ToString()

If I want the String to be exactly like the c# string, that code won't
do that, or? And if
String::Concat;
a/b.ToString();
does that, then please explain, because I don't understand.
 
int a = 5, b = 10;
String* s = String::Concat(a.ToString(), b.ToString());
s = String::Concat(s, S"blah");
 
s = String::Concat("blabla bla", a.ToString(), "bla bla bla", b.ToString());
// String::Concat supports 2 to 4 string instances
s = String::Concat(s, "."); // need to do the 5th one

is one way.

Creating a 5 element System::Array of Object*, initializing that with the
Strings and passing that to String::Concat in one go saves one string
allocation.

Note that the Whidbey version of C++ will make this much closer to the C#
support since we will both support implicit boxing and Param arrays.

Ronald Laeremans
Visual C++ team
 
Back
Top