String Concatenation

billy_bob169

Active member
Joined
Jan 30, 2003
Messages
32
Location
Minnesota
I am trying to Concatenate two strings in a VS.NET 2003 C++ Windows application, and I cannot seem to get it to work. Does anyone have any ideas? The statement doesnt do anything...the compiler does not blow up either! The MessageBox just shows the first string! :(

{
String *msg = "Customer Order\n";
msg->Concat(S" Processors\n");
MessageBox::Show(msg);
}
 
For anyone else who runs into this, this is how I got it to work:

{
String* msg = "Customer Order\n";
msg = String::Concat(msg, S" Processors\n");
MessageBox::Show(msg);
}

Not quite sure hom to get the "msg->Concat(S"String2");" to work, but if anyone figures it out, I would like to know.
Good Luck!
 
Concat is a static method of the String class, so even when you were calling msg->Concat, you were really just calling the static one which obviously doesnt modify any source string.
 
I see. So I have to code it as such:
{
String* msg = "Customer Order\n";
msg = msg->Concat(msg, S" Processors\n");
MessageBox::Show(msg);
}
Thanks Divil
 
Back
Top