Qus:    What is difference between string and string builder?
Dec 11, 2020 21:08 DotNet 2 Answers Views: 1345 PADMAKEECHU

 String a =”GangBoard”;

String b =”Online Training”

Stirng C = a + b ;

it will create three separate memory in the Heap

Whereas

Stringbuilder s = new stringbuilder();

s.append(“GangBoard”);

s.append(“Online Training”);

//It will create single instance memory in the Heap

Prev Next
Answers (2)
PARTH Dec 12, 2020 08:50
Answer:   A string is immutable means you cannot change it after it was created. Any operation that appears to change the string instead returns a new instance whereas when you need a mutable string, such as where you need to change lots of things, you use a StringBuilder which is a buffer of characters that can be changed.

SHIVA Dec 12, 2020 14:23
Answer:   String a =”GangBoard”;
String b =”Online Training”
Stirng C = a + b ;
it will create three separate memory in the Heap
Whereas
Stringbuilder s = new stringbuilder();
s.append(“GangBoard”);
s.append(“Online Training”);
//It will create single instance memory in the Heap

Post Your Answer
Guest User

Not sure what solution is right for you?

Choose the right one for you.
Get the help of the experts and find a solution that best suits your needs.


Let`s Connect