C# String Insert
Description
String Insert
returns a new string in which a specified
string is inserted at a specified index position in this instance.
Syntax
String.Insert
has the following syntax.
public string Insert(
int startIndex,
string value
)
Parameters
String.Insert
has the following parameters.
startIndex
- The zero-based index position of the insertion.value
- The string to insert.
Returns
String.Insert
method returns A new string that is equivalent to this instance, but with value inserted
at position startIndex.
Example
The following console application provides a simple demonstration of the Insert method.
using System;// w ww .j a v a 2 s. c om
public class Example {
public static void Main()
{
String strTarget = "asdf".Insert(1, "value");
Console.WriteLine(strTarget);
}
}
The code above generates the following result.