how to counts the character in string using c#

Gow.Net
Posted by Gow.Net under C# category on | Points: 40 | Views : 1304
  string inputstr;
Console.WriteLine("Enter Tex");
inputstr=Console.ReadLine();
string a;
Console.WriteLine("Enter character to find");
a =Console.ReadLine();

Regex exp = new Regex(a, RegexOptions.IgnoreCase);
int count = exp.Matches(inputstr).Count;
Console.WriteLine(count);
Console.ReadKey();

Comments or Responses

Login to post response