Concat two strings  
Author Message
Tryin2Bgood





PostPosted: Visual C# Language, Concat two strings Top

I got two strings....string1 and string2 and want to show a dash "-" between them so i did it like so

string1 + "-" + string2... but i dont think that works.....can anyone point me in the right direction. I need to get two strings concatanated with a dash - separating them.....




Visual C#14  
 
 
Prasant Swain





PostPosted: Visual C# Language, Concat two strings Top

have you tested it it will work, you can concat strings like this way you have specified.

 
 
ahmedilyas





PostPosted: Visual C# Language, Concat two strings Top

you can do this:

string finalString = String.Concat(string1, "-", string2);

or

string finalString = string1 + "-" + string2;

or

StringBuilder theBuilder = new StringBuilder();

theBuilder.Append(string1);

theBuilder.Append("-");

theBuilder.Append(string2);

MessageBox.Show(theBuilder.ToString());

do any of these work for you