For which one of the following reasons would a builder use StringBuilder over string?
-
Due to its nature as a reference type, StringBuilder has a smaller footprint than string,thereby allowing more efficent memory management.
-
StringBuilder is inherently more efficent due to its nature as a reference type comparedto string, which is a value type
-
StringBuilder allows for dynamic appending of types; string creates a new string every time it is appended to.
-
StringBuilder has the ability to accept objects other than string in order to build a string by automatically calling the ToString method on the object.
-
Regular expressions are built into StringBuilder, allowing for much more efficent text processing than what could usually be achieved by using a string.
StringBuilder is mutable and efficient for multiple string modifications. Each string append creates a new string object in memory (strings are immutable), while StringBuilder modifies the same buffer internally, reducing memory allocations and garbage collection pressure. Options A and B incorrectly claim string is a value type (it's a reference type).