C# Saved Program: quiescent-rain

facebook share

Here's the online compiler accompanied with IDE at your service. This is a saved code by one of our users. Try it out or save your own from the IDE page and don't forget to leave a feedback. You can find that at the bottom of the page.


//This program will sort a list using LINQ
using System;
using System.Collections.Generic;
using System.Linq;

namespace Sample
{
    public delegate int Addition(int a, int b);
class Program
{
    static void Main()
    {
   
        string Name="sachin tike";
        string result="";
        List<Extra> lst = new List<Extra>();
        int count = 0;
        
        for(int i= 0 ;i< Name.Length ;i++)
        {
            count = 0;
            if(!result.Contains(Name[i]))
            {
                for(int j=0 ;j<Name.Length;j++)
                {
                    if(Name[j] == Name[i])
                        count++;
                }
                lst.Add(new Extra(){chr =Name[i],cnt = count});
            }
        }
        
        foreach(var item in lst)
        {
            Console.WriteLine("Char {0} Count {1}",item.chr,item.cnt);
        }
    }
  
}
    public class Extra
    {
        public char chr {get;set;}
        public int cnt {get;set;}
    }
}
Execute

Output

Press the execute button or CTRL + enter to run code.

Inputs