Ways of Joining Strings in Dot Net

Rajesh_Kumar
Posted by Rajesh_Kumar under C# category on | Points: 40 | Views : 823
//Using + Sign
string name1 = "Rajesh ";
string name2 = "Kumar Sathua";
string combined_names = name1 + name2;
Response.Write(combined_names);

//Using String.Concat method
combined_names = String.Concat(name1, name2);
Response.Write(combined_names);


//Using String.Join method
string[] names = { "Rajesh ", "Kumar ", "Sathua " };
combined_names = String.Join(" ", names);
Response.Write(combined_names);

Comments or Responses

Login to post response