How should I concatenate strings?

前端 未结 9 1428
不知归路
不知归路 2020-12-06 00:43

Are there differences between these examples? Which should I use in which case?

var str1 = \"abc\" + dynamicString + dynamicString2;

var str2 = String.Form         


        
9条回答
  •  旧巷少年郎
    2020-12-06 01:26

    var str3 = new StringBuilder
        .AppendFormat("abc{0}{1}", dynamicString, dynamicString2).ToString(); 
    

    the code above is the fastest. so use if you want it fast. use anything else if you dont care.

提交回复
热议问题