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?
s = "Apple"; //No of occurances of 'p'string
char[] c = s.ToCharArray();
int count = 0;
for(int i=0;i { if (c[i] = = 'p') { count++; } } Console.Write(count); Thanks.

AlanRank #669 · 3.6K reputationPosted Aug 7, 2007, 11:09 AM EDT
Here's another way:
string s = "Apple";
int count = s.Split('p').Length - 1;
jaguRita33 reputationPosted Aug 7, 2007, 11:20 AM EDT
AlanRank #669 · 3.6K reputationPosted Aug 7, 2007, 11:55 AM EDT
It's difficult to find anything comprehensive, apart from the MSDN documentation itself, but these two tutorials are not bad and cover the main methods and properties of the String class:
http://www.csharphelp.com/archives4/archive702.html
http://en.csharp-online.net/Manipulating_Strings_in_CSharp