Kuups <(E-Mail Removed)> wrote:
> I have a question regarding the count if character within a string
> like for example I have a string of
>
> e.g.
>
> 123#123#
>
> I would like to determine what is the code? of getting the # sign
> which the answer is 2.
public static int CountCharacters (string data, char c)
{
int count=0;
foreach (char x in data)
{
if (x==c)
{
count++;
}
}
return count;
}
--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too