User Tools

Site Tools


stringbuilder

This is an old revision of the document!


The StringBuilder

If you are processing strings, of course you can concatenate them using the + operator:

cString := "Hello" + " " + "from" + " " + "my" + " " + "X#" + " " + "program"

But if you are building longer strings, composed by many substrings, you should use the System.Text.StringBuilder class. Is is much more efficient when dealing with many string parts:

using System.Text

oSB := StringBuilder{}
oSB:Append( "Hello" )
oSB:Append( " " )
oSB:Append( "from" )                                                                                                           
oSB:Append( " " )
oSB:Append( "my" )
oSB:Append( " " )
oSB:Append( "X#" )
oSB:Append( " " )
oSB:Append( "program" )
System.Console.WriteLine( oSB:ToString() )
stringbuilder.1517086259.txt.gz · Last modified: 2018/01/27 20:50 by wolfgangriedmann