Imports System.Text
Module Tester
Sub Main()
Dim i As Integer
Dim buffer As StringBuilder = New StringBuilder("Hello, how are you?")
' use Length and Capacity properties
Console.WriteLine("buffer = " & buffer.ToString & _
vbCrLf & "Length = " & buffer.Length & vbCrLf & _
"Capacity = " & buffer.Capacity)
buffer.EnsureCapacity(75)
Console.WriteLine("New capacity = " & buffer.Capacity)
' truncate StringBuilder by setting Length property
buffer.Length = 10
Console.WriteLine("New Length = " & buffer.Length )
End Sub
End Module
buffer = Hello, how are you?
Length = 19
Capacity = 32
New capacity = 75
New Length = 10