c# interview questions and answers paper 217 - skillgunNote: Paper virtual numbers may be different from actual paper numbers . In the page numbers section website displaying virtual numbers .
What is StringBuilder in C# ?
StringBuilder in C# is a class which is used for manipulating string content (for appending as well as for removing content) and StringBuilder is mutable.
StringBuilder is a static class in C#.
StringBuilder is same as string.
None of the above points are valid for StringBuilder.
StringBuilder in C# is a class which is used for manipulating string content ( for appending as well as for removing content ) and StringBuilder is mutable .
Let us try to understand the meaning of mutability .
Assume we have two strings "skill" and "gun" now we want to concatenate both the strings .
If you do it by using string concatenation it will produce 2 strings in the memory , first string becomes in-accessible after performing concatenation and assigning resultant string into original string variable .
Ex: string s1 = " skill " ; s1= s1+ "gun";
The same string concatenation we can do without memory wastage using StringBuilder.
Ex: StringBuilder sb=new StringBuilder ("skill");
Why is stringbuilder's Append method is more efficient than simple string concatenation ?
StringBuilder is mutable,string is immutable.
StringBuilder is immutable,string is mutable.
Strings will store in heap,StringBuilders will store in stack.
None of the above.
StringBuilder is mutable,string is immutable. For each operation on string will generate new instance of string, but in case StringBuilder it is not.
What is the output of the below given code ?
public class Test
public static void Main(string args)
string str = "Hello\\\tskillgun";
Second backslash will be escaped by first backslash and \t will produce a tab space .
StringBuilder is present in which namespace ?
System.Text namespace contains StringBuilder class.
Back To Top