How can i find out of Number of occurances in string?I have used array to find out.Is there any other way (Use of IndexOf) to find out?
string
s =
"Apple"; //No of occurances of 'p'
char[] c = s.ToCharArray();
int count = 0;
for(int i=0;i<c.Length;i++)
{
if (c[i] = = 'p')
{ count++; }
}
Console.Write(count);
Thanks.