String Insert() - C# Tutorial
C# Course / Strings / String Insert()

String Insert()

BLUF: Mastering String Insert() is essential for building robust applications with the .NET ecosystem. This tutorial provides clear explanations and practical examples to help you understand and apply this C# concept.
Enterprise Development Tip: String Insert()

C# is a powerful, modern language for enterprise solutions. Discover how String Insert() enhances your development workflow in the guide below.

The C# Insert function is employed to place a specified string at a specific index position. The indexing starts at 0. Upon insertion of the specified string, a new modified string is returned.

Signature

Example

public string Insert(Int32 first, String second)

Parameters

first: It is used to pass as an index.

The second method is employed to insert the provided string at a specific 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#

Input Required

This code uses input(). Please provide values below:

Logic Practice
Install Logic Practice
Add to home screen for a faster app-like experience