StringBuilder.EnsureCapacity
Imports System
Imports System.Text
Public Class MainClass
Shared Sub Main()
Dim buffer As StringBuilder = _
New StringBuilder("Hello, how are you?")
Dim output As String = "buffer = " & buffer.ToString & _
vbCrLf & "Length = " & buffer.Length & vbCrLf & _
"Capacity = " & buffer.Capacity
buffer.EnsureCapacity(75)
Console.WriteLine("New capacity = " & _
buffer.Capacity)
buffer.Length = 10
Console.WriteLine("New Length = " & _
buffer.Length & vbCrLf & "buffer = ")
End Sub ' Main
End Class
Related examples in the same category