Insert Method regarding Strings in C#

In this article we will discuss about how to use the insert method in C# regarding string.
  • 2824

Modify a string in C#

The Insert method inserts a specified string at a specified index position in an instance. For example, the following source code inserts a string at the end of the string.


using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 namespace ConsoleApplication4
     class Program
         static void Main(string[] args)
             string sentence = "Mahesh Chand is an author";
             Console.WriteLine("Original String: {0}", sentence);
             string insertString = " and founder of C# Corner";
             sentence = sentence.Insert(sentence.Length, insertString);
             Console.WriteLine("Final String");

Ask Your Question 
Got a programming related question? You may want to post your question here


More Articles

© 2020 DotNetHeaven. All rights reserved.