Κυριακή, Ιουλίου 27, 2003

StringBuilders Explained [Jul. 21, 2003]

"Visual Basic programmers have long enjoyed ease in string manipulations. It is easy to create a string, split it up, concatenate multiple strings, etc. For example, the following code sample illustrates how you could append one string to another to become one:

Dim st As String

st = 'Hello'
st += ' World!'

However, this seemingly innocent piece of code is not the recommended way to perform string manipulations in .NET. This is because strings in NET are immutable, which means that once a string variable is assigned a value, it cannot be changed. If the value of a string variable is changed, another string object is created during runtime. In the above code sample, two string objects are involved; one for the initialization and one for the concatenation."

O'Reilly Network - StringBuilders Explained

Δεν υπάρχουν σχόλια: