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?
Suggested Answer:A🗳️
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.
String.Concat Method concatenates one or more instances of String, or the String representations of the values of one or more instances of Object. However, all strings to concatenate must be given as parameters. In this scenario we have an unknown number of strings and therefore cannot pass them as paramaters.
the answer in this case is B
String.Concat is the same as the "+" operator (see https://docs.microsoft.com/en-us/dotnet/api/system.string.concat?view=netcore-3.1#remarks), so StringBuilder shuold be the correct answer
Answer is B
https://docs.microsoft.com/en-us/dotnet/csharp/how-to/concatenate-multiple-strings
"where you don't know how many source strings you are combining, and the actual number of source strings may be quite large"
A is correct.
minimize the amount of memory.
StringBuild does same job, but more memory.
upvoted 2 times
...
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
testing
Highly Voted 5 years, 9 months agosupersunny
Highly Voted 5 years, 4 months agoM62
Most Recent 3 years, 10 months agoDaGrooveNL
3 years, 10 months agonoussa
3 years, 11 months agoCarpeDM
4 years, 2 months agoramsi05
4 years, 6 months agocomoon
4 years, 8 months agoJamieHaywood
4 years, 10 months agoBitMan20
4 years, 11 months agoGods_Kenny
5 years agodakuan
5 years, 1 month ago