public void CharCount()
{
string str = Console.ReadLine();
int length = str.Length;
char[] charArr = new char[length];
for (int i = 0; i < length; i++) //Converting String to Char Array
{
charArr[i] = str[i];
}
for (int i = 0; i < length; i++)
{
bool flag = false;
for (int k = i - 1; k >= 0; k--) //Checking whether the current char already repeated or not
{
if (char.ToUpper(charArr[i]) ==char.ToUpper(charArr[k]))
{
flag = true;
}
}
if (!flag)
{
int count = 1;
for (int j = i+1; j < length; j++)
{
if (char.ToUpper(charArr[i]) ==char.ToUpper(charArr[j]))
{
count++;
}
}
Console.WriteLine(char.ToLower(charArr[i]) + "=" + count);
}
}
}Here we will see how to Get Count of Occurrence of Characters in String using C#.