vasanth krishna

vasanth krishna

  • NA
  • 44
  • 56k

Indexof() explain this steps clearly....

Jul 18 2013 2:08 PM
void main()
{
string name;
 name = Console.ReadLine();
string s1 = Console.ReadLine();
Console.WriteLine(text1.cou(name,s1));
}
 class  text1
  {
 public static int cou(string name,string no)
{
int i = 0,c=0;
 while((i=name.IndexOf(no,i))!=-1) // Explain this loop ,how it work
 {
i = i + no.Length;
 c++;
}
return c;
}
}

Answers (3)