Insert and Remove of the StringBuilder class : StringBuilder « Language Basics « VB.Net






Insert and Remove of the StringBuilder class

Insert and Remove of the StringBuilder class
  
Imports System
Imports System.Text

Public Class MainClass

   Shared Sub Main()
      Dim objectValue As Object = "hello"
      Dim stringValue As String = "good bye"
      Dim characterArray As Char() = {"a"c, "b"c, "c"c, _
         "d"c, "e"c, "f"c}

      Dim booleanValue As Boolean = True
      Dim characterValue As Char = "K"c
      Dim integerValue As Integer = 7
      Dim longValue As Long = 1123456
      Dim singleValue As Single = 2234.4325
      Dim doubleValue As Double = 33.3
      Dim buffer As StringBuilder = New StringBuilder()

      ' insert values into buffer
      buffer.Insert(0, objectValue)
      buffer.Insert(0, "  ")
      buffer.Insert(0, stringValue)
      buffer.Insert(0, "  ")
      buffer.Insert(0, characterArray)
      buffer.Insert(0, "  ")
      buffer.Insert(0, booleanValue)
      buffer.Insert(0, "  ")
      buffer.Insert(0, characterValue)
      buffer.Insert(0, "  ")
      buffer.Insert(0, integerValue)
      buffer.Insert(0, "  ")
      buffer.Insert(0, longValue)
      buffer.Insert(0, "  ")
      buffer.Insert(0, singleValue)
      buffer.Insert(0, "  ")
      buffer.Insert(0, doubleValue)
      buffer.Insert(0, "  ")

      Console.WriteLine("buffer after inserts:" & vbCrLf & _
         buffer.ToString() )

      buffer.Remove(12, 1)
      buffer.Remove(2, 4) 

      Console.WriteLine("buffer after Removes:" & vbCrLf & _
         buffer.ToString())

  End Sub ' Main

End Class


           
         
    
  








Related examples in the same category

1.Use StringBuilder for fast processing stringsUse StringBuilder for fast processing strings
2.StringBuilder Performance Test
3.StringBuilder: Char and ReplaceStringBuilder: Char and Replace
4.Demonstrating StringBuilder class constructorsDemonstrating StringBuilder class constructors
5.StringBuilder Length and CapacityStringBuilder Length and Capacity
6.Use StringBuilder IndexerUse StringBuilder Indexer
7.StringBuilder Append methodsStringBuilder Append methods
8.StringBuilder method AppendFormatStringBuilder method AppendFormat
9.StringBuilder Replace methodStringBuilder Replace method
10.Append String to StringBuilderAppend String to StringBuilder
11.Append bool data type values to a StringBuilder object.
12.Append SByte data type values to a StringBuilder object.
13.Insert String to StringBuilder
14.Insert char array to StringBuilder
15.Insert Object to StringBuilder
16.Insert xInt32 to StringBuilder
17.Insert System.SByte to StringBuilder
18.StringBuilder Class represents a mutable string of characters
19.Append three characters (D, E, and F) to the end of the StringBuilder
20.Append a format string to the end of the StringBuilder
21.Display the number of characters in the StringBuilder and its string
22.Insert a string at the beginning of the StringBuilder
23.Replace all uppercase A's with lowercase A's
24.TextElementEnumerator Class enumerates the text elements of a string.
25.TextInfo.ToTitleCase Converts the specified string to titlecase.
26.FieldAttributes Enumeration specifies flags that describe the attributes of a field.
27.BindingFlags.Public Or BindingFlags.Instance
28.BindingFlags.Public Or BindingFlags.Static
29.FileStream Class Exposes a Stream around a file
30.FileStream("c:\Variables.txt", FileMode.Append, FileAccess.Write, FileShare.Write)
31.Marks each type of member that is defined as a derived class of MemberInfo.
32.StringBuilder Class represents a mutable string of characters
33.Create StringBuilder class that starts with a specified capacity and can grow to a specified maximum.
34.Create StringBuilder class using the specified string.
35.Create StringBuilder class using the specified string and capacity.
36.Create StringBuilder class from the specified substring and capacity.
37.Appends various data to StringBuilder
38.StringBuilder.AppendFormat Method
39.StringBuilder.AppendLine Method appends line terminator to the end of the current StringBuilder object.
40.StringBuilder.Capacity Property gets or sets the maximum number of characters that can be contained
41.StringBuilder.Clear Method removes all characters from the current StringBuilder instance.
42.StringBuilder.Insert Method
43.StringBuilder.Remove removes the specified range of characters from this instance.
44.StringBuilder.Replace replaces all occurrences of a character in this instance with another specified character.