What should you include in the code?

You need to write a method that combines an unknown number of strings. The solution must minimize the
amount of memory used by the method when the method executes.
What should you include in the code?

You need to write a method that combines an unknown number of strings. The solution must minimize the
amount of memory used by the method when the method executes.
What should you include in the code?

A.
The String.Concat method

B.
The StringBuilder.Append method

C.
The + operator

D.
The += operator

Explanation:
A: String.Concat Method
Concatenates one or more instances of String, or the String representations of the values of one or more
instances of Object.



Leave a Reply 5

Your email address will not be published. Required fields are marked *


JS1985

JS1985

String.Concat is the better one if you know in advance how many number of strings you are going to combine.

StringBuilder.Append is the better one if you do not know in advance how many number of strings you are going to combine.

That makes B the right answer.