How to find Repetitions of character in to given String

Repetitions of character :

How to find Repetitions of character in to given String. In this post we seen fallowing thing, First how to take a Static String in to the Asp.net by C#, how to take character in c# with Assign value, how to make a function that take two argument . Occurrences refer to the repetitions of the character in to given string,





Occurrences refer to the repetitions of the character in to given string,


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        String str = " PARIJAT ,,mishra";
        Char c=',';

        int count = find(str,c);//call function................................

        Response.Write(count);
    }


// function.............................................................................
    public int find(String str,char c)
    {
        string Str1 = str.ToLower();
        int charCount=0;
        for (int i = 0; i < Str1.Length; i++)
        {
            if (Str1[i] == c)
            {
                charCount++;
            }
        }

        return charCount;
    }
}


here we make a find function for find Occurrences. and print this.


Other Post :

Comments

Popular posts from this blog