Is concatenating with an empty string to do a string conversion really that bad?

后端 未结 9 954
别那么骄傲
别那么骄傲 2020-12-03 04:45

Let\'s say I have two char variables, and later on I want to concatenate them into a string. This is how I would do it:

char c1, c2;
// ...

Str         


        
9条回答
  •  鱼传尺愫
    2020-12-03 05:14

    Unless your app needs every ounce of performance, write the code that's quicker to write and easier to read. "" + is a slower-to-execute syntax, but it certainly seems easier to read every time I've used it.

提交回复
热议问题