Walmart Interview Question: What is the difference betwee... | Glassdoor

Interview Question

Senior .NET Programmer Analyst Interview Bentonville, AR

What is the difference between String and StringBuilder

  classes in .NET?
Answer

Interview Answer

1 Answer

0

string is immutable. Use Stringbuilder to build strings from smaller strings. If you use string for that like
string s = "this" + " assigns" + " lots" + "of" + " little" + " strings";
then for each intermediate sum, a new string is allocated, and the smaller strings used before have to be garbage collected.

programmer squirrel on Sep 9, 2012

Add Answers or Comments

To comment on this, Sign In or Sign Up.