How can I join Strings?

  • Thread starter Thread starter David
  • Start date Start date
D

David

String* str1;

String* str2;

String* s;

str1="Rado";

str2="Robes";

s= str1 + ' ' + str2;



But VC++ write me error> d:\My projects\Visual C++\listview\Form1.h(125):
error C2845: '+' : cannot perform pointer arithmetic on __gc pointer
'System::String __gc *'


BUT when I declare "Strings str;" It's bad too.

Where can be problem?

How can I join strings for example 7 strings and in the middle of each
string will be space?

Thanks.
 
String::Concat will join 2 strings

String* str1
String* str2
String* str3

str1 = "Hello "
str2 = "World"
str3 = String::Concat(str1, str2)

You can also use String::Format, which is similiar to sprintf, but it takes advantage of type checking in .Net

String* str1
String* str2
String* str3

str1 = "Hello"
str2 = "World"
str3 = String::Format("{0} {1}", str1, str2);
 
Back
Top