how to make a program which checks and count occurrences characters in a string in c#

In this article, I will show, how to make a program which checks and count occurrences characters in a string in c#

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq.Expressions;

namespace testconsole

{
    class Program
    {
     
        static void Main(string[] args)
        {

            string input = "this is Manvendrs Patel Blog ";
            string chekvalue = "";
            for  (int i = 0; i < input.Length; i++)

            {
            if (chekvalue.Contains(input[i].ToString()))
                {
                }
                else {
                    chekvalue = input[i] + chekvalue;
                    Console.Write(input[i] + " : ");
                    int count = 0;

                for (int j = 0; j < input.Length; j++)

                {

                    if (input[i] == input[j])

                    {

                        count++;

                    }

                }

                Console.WriteLine(count);
                }
             
            }

            Console.ReadLine();

     
            }

       
     
        }
     
    }



 

   




Comments

Popular posts from this blog

Bootstrap Modal Popup keep open on PostBack in ASP.Net

Resolved Issue in Asp core 3.0 serializersettings does not exist in AddJsonOptions

.Net most asked interview questions for experienced professionals (C#,Asp WEBFORM,MVC,ASP CORE,WEB API,SQL Server,Java Script,Jquery)