C# StringBuilder Insert(Int32, String, Int32)

Description

StringBuilder Insert(Int32, String, Int32) Inserts one or more copies of a specified string into this instance at the specified character position.

Syntax

StringBuilder.Insert(Int32, String, Int32) has the following syntax.


public StringBuilder Insert(
  int index,/*ww w .  jav a2 s . co  m*/
  string value,
  int count
)

Parameters

StringBuilder.Insert(Int32, String, Int32) has the following parameters.

  • index - The position in this instance where insertion begins.
  • value - The string to insert.
  • count - The number of times to insert value.

Returns

StringBuilder.Insert(Int32, String, Int32) method returns A reference to this instance after insertion has completed.

Example


using System;//from www  . jav a 2s  . co  m
using System.Text;

class Sample 
{
    public static void Main() 
    {
        StringBuilder sb = new StringBuilder("from java2s.com");
        
        sb.Insert(3, "abc", 2);
        Console.WriteLine(sb.ToString());
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Text »




ASCIIEncoding
Encoding
EncodingInfo
StringBuilder
UnicodeEncoding
UTF8Encoding