.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Lee Hnetinka

Home >> Code Snippets >> Collections >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Count of repeated characters in String in C#.net

Posted By:Narayanan       Posted Date: March 13, 2012    Points: 40    Category: Collections    URL: http://www.dotnetspark.com  

Here, I will give a Count of repeated Charaters in a String using C#.net

Function/ Methode:
public static int countofrepeatedchar(string inputstring, char ch)
            char[] Inputstring = inputstring.ToCharArray();
            char Ch = ch;
            int cntofchar = Inputstring.Length;
                foreach (char chr in Inputstring)
                    if (chr == Ch)

            return result;

Call the Function
int resy = countofrepeatedchar("123456123",'4');

Output Result :


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend