protected void Count(object sender, EventArgs e)
{
string test = "Vasanth";
List<string> str = new List<string>();
char[] chrs = test.ToCharArray();
for (int i = 0; i < chrs.Length; i++) {
var s = chrs[i] + " " + Occurence(test, chrs[i]);
if (str.IndexOf(s) == -1)
{
str.Add(s);
}
}
Label1.Text = string.Join("<br />", str);
}
private int Occurence(string text, char chr)
{
int i = 0, count = 0;
while ((i = text.IndexOf(chr, i)) != -1)
{
count++;
i++;
}
return count;
}