Skip to main content

How To Count The Number Of Characters Occurrence In A String in Asp.net(C#).

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
namespace Programming.CharacterOccurence
{ 

    class Test
    { 

        static void Main() { 

            String input = "Web Developer"; 
            string ChartoFind = "r"; 
            int totallengthofinput = input.Length; 
            int LengthOfInputWithOutCharToFind = input.Replace(ChartoFind, "").Length; 
            int resultcount = totallengthofinput - LengthOfInputWithOutCharToFind;
            Console.WriteLine("Number of times occured the character r occured is : {0}", resultcount); 
            Console.ReadLine(); 

        } 

    } 

}  

Comments