Which method offers the best performance to join together two strings ?
1.
2.
3.
I am looking for a method that will be used in general (short, long, very long strings which are made from 2 strings or more) ... for now I am using the 1st and the 2nd but I saw a post (can't find it) that suggested that for long strings composed of many parts (not just two) it is performance wise to use the 3rd method ...
1.
B4X:
Dim finalString As String = String1 & String2
B4X:
Dim finalString As String = $"${String1}${String2}"$
B4X:
Dim sb As StringBuilder
sb.Initialize
sb.Append(String1)
sb.Append(String2)
Dim finalString As String = sb.ToString
I am looking for a method that will be used in general (short, long, very long strings which are made from 2 strings or more) ... for now I am using the 1st and the 2nd but I saw a post (can't find it) that suggested that for long strings composed of many parts (not just two) it is performance wise to use the 3rd method ...