Hi all:
If i'm not wrong, StringBuilder should faster than string concat using
&.
But the following code:
1:
Dim s as string
For i As Integer = 1 To 1000000
s = "11111111111111111111111111111111" & _
"11111111111111111111111111111111" & _
"11111111111111111111111111111111" & _
"11111111111111111111111111111111" & _
"11111111111111111111111111111111" & _
"11111111111111111111111111111111" & _
"11111111111111111111111111111111" & _
"11111111111111111111111111111111" & _
"11111111111111111111111111111111" & _
"11111111111111111111111111111111" & _
"11111111111111111111111111111111" & _
"11111111111111111111111111111111" & _
"11111111111111111111111111111111" & _
"11111111111111111111111111111111" & _
"11111111111111111111111111111111" & _
"11111111111111111111111111111111" & _
"11111111111111111111111111111111" & _
"11111111111111111111111111111111" & _
"11111111111111111111111111111111" & _
"11111111111111111111111111111111"
Next
2:
Dim sb As StringBuilder = New StringBuilder
For i As Integer = 1 To 1000000
sb.Append("11111111111111111111111111111111")
sb.Append("11111111111111111111111111111111")
sb.Append("11111111111111111111111111111111")
sb.Append("11111111111111111111111111111111")
sb.Append("11111111111111111111111111111111")
sb.Append("11111111111111111111111111111111")
sb.Append("11111111111111111111111111111111")
sb.Append("11111111111111111111111111111111")
sb.Append("11111111111111111111111111111111")
sb.Append("11111111111111111111111111111111")
sb.Append("11111111111111111111111111111111")
sb.Append("11111111111111111111111111111111")
sb.Append("11111111111111111111111111111111")
sb.Append("11111111111111111111111111111111")
sb.Append("11111111111111111111111111111111")
sb.Append("11111111111111111111111111111111")
sb.Append("11111111111111111111111111111111")
sb.Append("11111111111111111111111111111111")
sb.Append("11111111111111111111111111111111")
sb.Append("11111111111111111111111111111111")
Next
Why stringbuiler is slower ?
Thanks
JCVoon