T
Tony Johansson
Hello!
I read in a book and here is a question and the answer that I'm not
satisfied with.
When should you use the StringBuilder class instead of the String class.
1.When building a string from shorter strings.
2.When working with text data longer than 256 bytes.
3.When you want to search and replace the contents of a string
4.When a string is a value type.
The answer that I would choose would be 3 because string object is immutable
so
here is it an advantage to use the StringBuilder class but
according to the book is the right answer 1.
But if you build a string from shorter strings you don't have to use a
StringBuilder class as
string s = "This" + "is" + "a" + "Test";
I can accept numer 1 if they mean this.
string s;
s += "This";
s += "is";
s += "a";
s += "Test";
But it is somewhat unclear what they mean when they say building a string
from shorter strings.
Can somebody give a comment how the book can say that the right answer is
number 1
//Tony
I read in a book and here is a question and the answer that I'm not
satisfied with.
When should you use the StringBuilder class instead of the String class.
1.When building a string from shorter strings.
2.When working with text data longer than 256 bytes.
3.When you want to search and replace the contents of a string
4.When a string is a value type.
The answer that I would choose would be 3 because string object is immutable
so
here is it an advantage to use the StringBuilder class but
according to the book is the right answer 1.
But if you build a string from shorter strings you don't have to use a
StringBuilder class as
string s = "This" + "is" + "a" + "Test";
I can accept numer 1 if they mean this.
string s;
s += "This";
s += "is";
s += "a";
s += "Test";
But it is somewhat unclear what they mean when they say building a string
from shorter strings.
Can somebody give a comment how the book can say that the right answer is
number 1
//Tony