3
Answers

Indexof() explain this steps clearly....

Ask a question
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)