ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Count occurrences of character in string in C#<pre class="brush: csharp"> protected void Count(object sender, EventArgs e) { string test = &#34;Vasanth&#34;; List&lt;string&gt; str = new List&lt;string&gt;(); char[] chrs = test.ToCharArray(); for (int i = 0; i &lt; chrs.Length; i++) { var s = chrs[i] + &#34; &#34; + Occurence(test, chrs[i]); if (str.IndexOf(s) == -1) { str.Add(s); } } Label1.Text = string.Join(&#34;&lt;br /&gt;&#34;, str); } private int Occurence(string text, char chr) { int i = 0, count = 0; while ((i = text.IndexOf(chr, i)) != -1) { count++; i++; } return count; }</pre> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/621937/Count-occurrences-of-character-in-string-in-C/https://www.aspforums.net:443/Threads/621937/Count-occurrences-of-character-in-string-in-C/Tue, 17 Apr 2012 00:13:18 GMT