Function/ Method:
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)
{
result++;
}
}
return result;
}
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)
{
result++;
}
}
return result;
}
int res = countofrepeatedchar("123456123",'4'); MessageBox.Show(res.ToString());
No comments:
Post a Comment