c#

How to count characters of a string in c#?

Character counting explain you how we can count the character of string. 

Ex: World

In this word there are 5 character. This we can explain programmatically.

using System;  

public class Program {  

    public static void Main() {  

        string strFirst;  

        char charCout;  

        int Count = 0;  

        Console.Write(“Enter Your String:”);  

        strFirst = Console.ReadLine();  

        Console.Write(“Enter Count Character:”);  

        charCout = Convert.ToChar(Console.ReadLine());  

        Console.Write(“Your Character Count:”);  

        foreach(char chr in strFirst) {  

            if (chr == charCout) {  

                Count++;  

            }  

        }  

        Console.Write(Count);  

    }