What?s the difference between System.String and
System.StringBuilder classes?

Answers were Sorted based on User's Feedback



What?s the difference between System.String and System.StringBuilder classes?..

Answer / sundarchum

Both the String and StringBuilder class are used to store
strings. One exception is when we change the value in the
string it will create a new String object is creating in
memory and assign the new value.

eg: String name = "Sundar";

A new name object is creating in memory and the
value "Sundar Rahul" is assinging to the newly created
space.

eg: String name = "Sundar Rahul";

But StringBuilder class occupies the same space even if you
change the value.

StringBuilder gives you better performance than String
class when you perform string manipulations like string
concatenation.

You can use StringBuilder's Append() method to use
concatenation and for String use "+".

Is This Answer Correct ?    3 Yes 0 No

What?s the difference between System.String and System.StringBuilder classes?..

Answer / guest

System.String is immutable, System.StringBuilder was
designed with the purpose of having a mutable string where a
variety of operations can be performed

Is This Answer Correct ?    2 Yes 0 No

What?s the difference between System.String and System.StringBuilder classes?..

Answer / akash

Both the String and StringBuilder class are used to store
strings. One exception is when we change the value in the
string it will create a new String object is creating in
memory and assign the new value.

eg: String name = "Sundar";

A new name object is creating in memory and the
value "Sundar Rahul" is assinging to the newly created
space.

eg: String name = "Sundar Rahul";

But StringBuilder class occupies the same space even if you
change the value.

StringBuilder gives you better performance than String
class when you perform string manipulations like string
concatenation.

You can use StringBuilder's Append() method to use
concatenation and for String use "+".

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Sharp Interview Questions

How do you comment out code in c#?

0 Answers  


How long has c# been around?

0 Answers  


Why to use “using” in c#?

0 Answers  


Is nullable type c#?

0 Answers  


What is the best method to fill the GridView. using SqlDataReader or Dataset and why

5 Answers   CA,






Explain constructor.

7 Answers   Wipro,


What is extension method in c# and how to use them?

0 Answers  


What is desktop example?

0 Answers  


Does c# support multiple inheritance (mi)?

0 Answers  


What do you mean by winforms in c#?

0 Answers  


Explain publishers and subscribers in events.

0 Answers  


how to Create a datagridview control with check box column with 8rows in it, the maximum number of check boxes checked should be 3, when user checks the 4th corresponding message should be displayed and check box should be checked. User can uncheck the checked boxes Note: read-only property should not be used

0 Answers   HCL, NIC,


Categories