用c# 编写窗口程序:在一个文本框中输入一个字符串,查找某个字符在该字符串中出现的次数

如题所述

第1个回答  2010-11-11
string a= 'a';
string b=txtbox1.text;
int count =0;
用一个for循环,将b截取的字符与a字符进行比较,如果相同,就count++。
for(int i=0;i<b.length;i++)

if(a.equeal('b截取出来的那个字符'))
{
count++;
}
第2个回答  2010-11-11
int seek(char ch,string str) {
int i,num=0;
for(i=0;i<str.length;i++) {
if(str[i]==ch) {num++;}
}
return num;
}

用这个函数就好了本回答被提问者采纳
相似回答