Below code will help out , how to find unique characters from string .
char[] chars = "abdccddbbzcyxzwwwww"?.ToCharArray();
{
var dic = new Dictionary<char, int>();
foreach (var c in chars)
{
if (!dic.ContainsKey(c))
{
dic[c] = 0;
}
dic[c]++;
}
foreach (var charCombo in dic)
{
if (charCombo.Value == 1)
{
Console.WriteLine(charCombo.Key.ToString());
}
}
}
No comments:
Post a Comment