how to counts the character in string using c#

Gow.Net
Posted by Gow.Net under C# category on | Points: 40 | Views : 1143
 int count = 0;
string st = "Gowthaman";
foreach (char a in st)
{
if(char.Equals(a,'a'))
{
count++;

}

}

Console.WriteLine(count.ToString());

Comments or Responses

Login to post response