Inserting string in a String Builder in C#

You can insert a string in a string builder by specifying the start position and the text that you need to insert.
Please remember that by using Append(), you can only insert at the end of the string builder object.
So, the insert method is provided here to insert at any position of the string builder object.


using System;
using System.Text;

namespace forgetCode
    class program
        public static void Main()

            StringBuilder sb1 = new StringBuilder("Time is gold");

            sb1.Insert(0, "Try to use the time since ");


Try to use the time since Time is gold

In the above code, the text was inserted at the first position of the string builder.