T
Tee
String Builder & String, what's the difference.
and when to use which ?
Thanks.
and when to use which ?
Thanks.
String Builder & String, what's the difference.
and when to use which ?
Thanks.
instead
Odd that Microsoft doesn't recommend it that way...
Once a StringBuilder class is instantiated, it is indeed much faster.
However, the instantiation of an Object is costly in itself. A String is a
primitive, which means that unless you treat it as an object, it is
certainly much faster to use than an Object (which is why the .Net framework
includes primitives).
In addition, when you instantiate a StringBuilder, it
allocates the default amount of Memory needed to hold its entire buffer (the
buffer is how it avoids re-allocating Memory). Therefore, if you are doing a
small amount of work with a string, it may indeed more efficient NOT to use
a StringBuilder. Consider the following:
StringBuilder s = new StringBuilder("Hello Mom").;
s.Append(", I mean, Mother");
Response.Write(s.ToString());
string s = "Hello Mom";
s += ", I mean, Mother";
Response.Write(s);
Which runs faster? Which uses the most Memory?
For this example, a stringbuilder would be overkill.
Please do not take things I say out of context!it with shortstrings as above no more. Then some weeks ago, Jay B stated to
me, that it was faster to do it as above. (You understand it probably, the
fire was on).
Please do not take things I say out of context!
I'm not sure which thread you think I told you that, but its obvious to me
you are mis-quoting me!
Again, you give an answer if you are the only one who knows this or someoneThe article that I referenced in that messages tells you when you would use
a StringBuilder and multiple appends and tells you when you would use String
concatenation.
You need to read the article itself, to know when to use which.