Technical-Talk banner
Home   About Us   Contact Us
Question:

You are the ASP.NET developer and creating an ASP.NET application. The application contains a page which uses string concatenation to collect data from email messages and format that data to display on the page. You want to make sure that page should be displayed as fast as possible, which action should you take?
A. Write code that uses the Concat method of the String object.
B. Write code that uses the Substring method of the String object.
C. Write code that uses the Append method of the StringBuilder object.
D. Write code that uses the plus-sign (+) operator to concatenate the strings.



Correct Answer:
C
Explanation:
The Append method of the StringBuilder object appends the string representation of the specified object to the end of this instance.
Incorrect Answers
A: The 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, compared to the Append method of the StringBuilder object, the Concat method create new instances, and is therefore not the preferred method.
B: The Substring method is used to select a part of a string. It can not be used to concatenate multiple strings.
D: This solution is a bit complex and slow, not the appropriate solution.

Google