The C# Insert method is used to insert the specified string at specified index number. The index number starts from 0. After inserting the specified string, it returns a new modified string.
Signature
Example
public string Insert(Int32 first, String second)
Parameters
first: It is used to pass as an index.
second: It is used to insert the given string at specified index.
Return
It returns a new modified string.
C# String Insert Method Example
Example
using System;
public class StringExample
{
public static void Main(string[] args)
{
string s1 = "Hello C#";
string s2 = s1.Insert(5,"-");
Console.WriteLine(s2);
}
}
Output:
Output
Hello- C#