Friday, July 18, 2003 - Posts

Quick Tip: String vs. StringBuilder

Ok, this is just a quick tip since I'm tired.

We're going discuss why you should ALWAYS use a StringBuilder (part of System.Text namespace) when doing any string manipulation.

Put simply, a string type is immutable and a StringBuilder is NOT.

Immutable means that after created it cannot be modfied, changed, etc. - This is what a string type is, if you add even just one character to a string using either the + or &

myString = myString & "HI"

A new string is created (an additional OBJECT is created)

A StringBuilder is NOT immutable (Mutable), so you can add, remove, modify, etc. a StringBuilder object and new objects will NOT be created. So, if you need to dynamically construct a string or manipulate one always use a StringBuilder object.

C# Example:

StringBuilder sb = new StringBuilder("You can pass in a string to the contstructor");
sb.Append(" and then add some more");

There are many other methods and properties of the stringbuilder object you should check out to make your life easier:

Check StringBuilder Class Browser

What is Wrong with DotNetJunkies Homepage????

Ok, I see about a ~50% approval of our home page, what gives? Please let us know, what we're missing so we can add it.

For that matter, what features are we lacking currently that we can add???

We are striving to be a larger, better, .NET community and we need your help! We have the connections to get the information you want and need but without feedback we don't know what that is?

I understand that we still have some bugs in this version of DotNetJunkies, some we are letting go by because we're working on a better system to replace the current and the others we are fixing. We have lots of new features and sections in the works, but you may think of something we haven't, it's happened a million times so let us know!

help@dotnetjunkies.com is the url to email or just respond to this post with your comments! Another avenue is our Forums we're on them all day long. And if all else fails, email me directly donny.mack@dotnetjunkies.com

Thanks for all your support!!