Charecter Count in a string
Hi friends,
I haven't found any separate function in c# to find the no of occurrence of one letter in one string.
Here is a simple function to find out no of occurrence of a character in string easily
static int CountChars(string value,char key)
{
int count = 0;
foreach (char c in value)
{
if (c==key)
{
result++;
}
}
return count;
}
we can pass string as value and letters as key and no of appearance will be returned by the function.
if u have any other idea please share with me
Thanks,
shyamal swaroop k.s
Hi
I have used this function and it is working quiet well.
Keep posting
Thanks