Concatenating

There are a couple of ways you can concatenate strings.


System.String.ConCat

string sName; 
sName = System.String.Concat("firstname", "lastname");


+ and += (with double quotes)

string sName; 
sName = "firstname" + "lastname"
sName = sName + "somethingelse"
sName += "somethingelse

& and &= (with double quotes)

string myString; 
myString = "firstname" & "lastname"

This can be used to amend a string to itself plus something else

sName = sName & "something else" 
sName &= "something else"

System.String.Join

Concatenates all the elements of a string array using a given separator

String.Join(seperator as string, 
      value() as string) as string
String.Join(seperator as string,
       value() as string, _
      startindex as Integer, _
     count as Integer) as string

StringBuilder

Everytime you concatenate a string a new address in memory is allocated
The existing string is copied to a new location with the newly string added
When you use StringBuilder the same position in memory is used

StringBuilder oStringBuilder = new StringBuilder(); 
foreach (var value in mystring)
{
   oStringBuilder.Append(value)
}

System.String.Format

Also called Composite Formatting
The Format method of the String class allows you to format a string and include one or more numeric or datetime values in it.
A strings can contain placeholders for arguments, the format {N} where N is an index that starts at 0.


string sResult; 
string sVariableName;
sVariableName = "Russell"
sResult = System.String.Format("The value of variable {0} is {1}", "sVariableName", sVariableName)
sResult = "The value of variable sVariableName is Russell"

String Interpolation

There is a cleaner format to allow you put expressions directly in the string literal to evaluate expressions.

string onestring = "one"; 
string twostring = "two";
WriteLine("contents : \ {onestring} \ {twostring}");


© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext