Best way to break long strings in C# source code

后端 未结 10 1482
伪装坚强ぢ
伪装坚强ぢ 2021-02-03 18:47

I am wondering what is the \"best practice\" to break long strings in C# source code. Is this string

\"string1\"+
\"string2\"+
\"string3\"

con

10条回答
  •  天涯浪人
    2021-02-03 19:26

    it really depends on what you need. Generally, if you need to concat strings, the best performance in runtime will be achieved by using StringBuilder. If you're referring in source code something like var str = "String1"+"String2" it will be converter into string str = "String1String2" on compilation. In this case you have no concatenation overhead

提交回复
热议问题