Inserting a string within string using C#

To insert a string withina string we use Insert method. This method takes two parameters.
First is start index where we want to insert. Second parameter is value which we want to insert.

Return type of this method is string. Here we will insert a string at 0 index. Output is shown before and after inserting the string.

string str = "like rain";
Console.WriteLine(str);
str = str.Insert(0, "I ");
Console.WriteLine(str);

Output

Like rain
I like rain

Comments

Popular posts from this blog

Check if ViewBag is null or doesn't exist

Using Progress Bar In C#

Jquery serer side datatables in asp.net