B4J Question String Concatenation

mindful

Active Member
Licensed User
Which method offers the best performance to join together two strings ?
1.
B4X:
Dim finalString As String = String1 & String2
2.
B4X:
Dim finalString As String = $"${String1}${String2}"$
3.
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 ...
 

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
Hi!

The post you are looking was between erel and ilan and erel demonstrated that stringbuilder is 10 times faster than the other 2 methods.

You may not find the post because it was on the chit chat section
 
Upvote 0
Top