Imports System
Public Class MainClass
Shared Sub Main()
Dim i As Integer
Dim StartTime As New DateTime()
Dim EndTime As New DateTime()
StartTime = DateTime.Now()
Dim theText As New System.Text.StringBuilder()
For i = 1 To 50000
theText = theText.Append("A")
Next
EndTime = DateTime.Now
Dim answer1, answer2 As Long
answer1 = EndTime.Ticks() - StartTime.Ticks()
StartTime = DateTime.Now()
Dim aString As String = ""
For i = 1 To 50000
aString = aString & "A"
Next
EndTime = DateTime.Now
answer2 = (EndTime.Ticks() - StartTime.Ticks())
Console.WriteLine("StringBuilder was " & answer2 / answer1 & " times faster.")
End Sub
End Class
|