'-'.join(number)
(Damn!! I think Python spoiled me... )
B4X:
Dim number = "123" As String
Dim output = number.CharAt(0) As String
For i = 1 To (number.Length - 1)
output = output & "-" & number.CharAt(i)
Next
Log (output)
'-'.join(number)
(Damn!! I think Python spoiled me... )
B4X:
Dim number = 123 As String
Dim output = number.CharAt(0) As String
For i = 1 To (number.Length - 1)
output = output & "-" & number.CharAt(i)
Next
Log (output)
Using stringbuilder (which is supposed to be faster for string appends):
B4X:
Dim number = "123" As String
Dim output as stringbuilder
output.append(number.CharAt(0))
For i = 1 To (number.Length - 1)
output.append("-" & number.CharAt(i))
Next
Log (output.tostring)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.