Insert method of StringBuilder : StringBuilder « Data Type « VB.Net Tutorial






Imports System
Imports System.Text

Class Sample
   Private Shared sb As StringBuilder

   Public Shared Sub Main()
      Dim xyz As String = "xyz"
      Dim abc As Char() =  {"a"c, "b"c, "c"c}
      Dim star As Char = "*"c
      Dim obj As [Object] = 0

      Dim xBool As Boolean = True
      Dim xByte As Byte = 1
      Dim xInt16 As Short = 2
      Dim xInt32 As Integer = 3
      Dim xInt64 As Long = 4
      Dim xDecimal As [Decimal] = 5
      Dim xSingle As Single = 6.6F
      Dim xDouble As Double = 7.7

      Dim xUInt16 As System.UInt16 = 8 
      Dim xUInt32 As System.UInt32 = 9
      Dim xUInt64 As System.UInt64 = 10 
      Dim xSByte As System.SByte = - 11
      
      sb = New StringBuilder()

      sb.Insert(3, xyz, 2)
      sb.Insert(3, xyz)
      sb.Insert(3, star)
      sb.Insert(3, abc)
      sb.Insert(3, abc, 1, 2)
      sb.Insert(3, xBool)    
      sb.Insert(3, obj)      
      sb.Insert(3, xByte)     
      sb.Insert(3, xInt16)    
      sb.Insert(3, xInt32)    
      sb.Insert(3, xInt64)    
      sb.Insert(3, xDecimal)  
      sb.Insert(3, xSingle)   
      sb.Insert(3, xDouble)   
      sb.Insert(3, xUInt16) 
      sb.Insert(3, xUInt32) 
      sb.Insert(3, xUInt64) 
      sb.Insert(3, xSByte)  

      Console.WriteLine(sb.ToString())

   End Sub 
End Class








2.40.StringBuilder
2.40.1.Demonstrating StringBuilder class constructors
2.40.2.StringBuilder: Insert string, Append and Replace
2.40.3.Append Char to StringBuilder
2.40.4.Demonstrating StringBuilder Append methods
2.40.5.StringBuilder AppendFormat
2.40.6.StringBuilder.AppendFormat: {0:D} is ${1: #,###.00}
2.40.7.Replace method.
2.40.8.Insert method of StringBuilder
2.40.9.StringBuilder: Length, Capacity, EnsureCapacity
2.40.10.Use StringBuilder Indexer
2.40.11.Demonstrating methods Insert and Remove of the StringBuilder class
2.40.12.Demonstrating method Replace
2.40.13.Use StringBuilder to reverse a string
2.40.14.StringBuilder.ToStrings
2.40.15.Performance difference between String and StringBuilder