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);
}
}
}