Maha

Maha

  • NA
  • 0
  • 326.5k

NP132 StringBuilder/Remove()

Aug 23 2008 10:57 AM

Hi Guys

 

NP132 StringBuilder/Remove()

 

In the following what is the function of Remove() method (highlighted in yellow). Because I am unable to understand the following second output. Please explain.

 

myStringBuilder = frRoomans, Romans, friends, iends

 

Thank you

 

using System;

using System.Text;

 

class MainClass

{

    public static void Main()

    {

        StringBuilder myStringBuilder = new StringBuilder();

 

        myStringBuilder.Append("friends");

 

        myStringBuilder.Insert(2, "friends, ");

        myStringBuilder.Insert(2, "Romans, ", 3);

 

        Console.WriteLine("myStringBuilder = " + myStringBuilder);

 

        myStringBuilder.Remove(4, 7);

        Console.WriteLine("myStringBuilder = " + myStringBuilder);

 

    }

}

/*

myStringBuilder = frRomans, Romans, Romans, friends, iends

myStringBuilder = frRoomans, Romans, friends, iends

*/


Answers (2)