1. What’s the difference between System.String and System.Text.StringBuilder classes?
    System.String is immutable.  System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed. 
     
  2. What’s the advantage of using System.Text.StringBuilder over System.String?
    StringBuilder is more efficient in cases where there is a large amount of string manipulation.  Strings are immutable, so each time a string is changed, a new instance in memory is created.
     
 
 
 

using System;
//csc string_index0f.cs
//Once upon a time there was great king named Vikramaditya. He had five distinct nobles in his cabinet. Kalidas was one of them
namespace stringindexof
{
public class IOfTest {
public void process(string str) {
string strSource = str;
Console.WriteLine("Search this String: :"+ strSource);
string strTarget = "";
int found = 0;
int dt_char = 0;
do {
Console.Write("Enter a search letter (hit Enter to exit) ==> ");
strTarget = Console.ReadLine();
if (strTarget != "") {
for (int i = 0; i < strSource.Length; i++) {
found = strSource.IndexOf(strTarget, i);
if (found > 0) {
dt_char++;
i = found;
}
else
break;
}
}
else
return;
Console.WriteLine("The search found "+ strTarget + " <" + dt_char + "> Times");
dt_char = 0;
} while ( true );
}
}
class test {
public static void Main()
{
Console.WriteLine("--Character Serach-----");
Console.Write("Enter a sentence : ");
string ss=Console.ReadLine();
IOfTest it = new IOfTest();
it.process(ss);
}
}
}