In this post we will see how to find duplicate characters in a string.For example we can identity how many times character S occurs in a string.
using System; using System.Collections.Generic; public class Program { public static void Main() { string temp="SHUKLAA"; Dictionary<char,bool> chars=new Dictionary<char,bool>(); foreach(char ch in temp) { if(!chars.ContainsKey(ch)) chars.Add(ch,true); else Console.WriteLine(string.Format("duplicate character is {0}",ch)) } } };

