What is the difference between System.String and
System.StringBuilder classes?
Answer Posted / shyam vishwakarma
String and StringBuilder class stores strings. But when you
cannot change a String object after creating one.
eg: String name = "Prasad";
By saying you cannot change the name object means you cannot
change the value in name object internally. When you change
the name object value to something else, a new String object
is creating in memory and assign the new value.
eg: name = "Prasad Reddy";
A new name object is creating in memory and the value
"Prasad Reddy" is assinging to the newly created space.
But StringBuilder class occupies the same space even if you
change the value.
If you are doing string concatenation StringBuilder class is
far better in performance than String class.
You can use StringBuilder's Append() method to use
concatenation.
Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
What is multiple interface in c#?
What is static classes?
Can a loop recorder detect a heart attack?
What is razor view in c#?
What is the relation between classes and objects?
Can an abstract class inherit from another abstract class c#?
Why do we use generics in c#?
What is the difference between new and override in c#?
How to update the gui from another thread in c#?
write a C# Program add two matrix ?
What is appdomain in c#?
Is array passed by reference in c#?
Why do we use static methods in c#?
How long can a string be c#?
Does c# support multiple inheritance (mi)?