c#什么方法可以判断字符串中包含某个字符的个数?

注意我说的是“方法”,超过3行代码的就别回了

show.EndsWith("你好");
即为字符show 内,是"你好"

show.Length;
show字符内的个数

比如:show="123456"

show.Length=6
温馨提示:内容为网友见解,仅供参考
第1个回答  推荐于2016-10-25
string aa=" abcd6789@21cn.com";
方法1:aa.IndexOf ("b",1,);
方法2:有需要用正则表达式
string emailflag = "@";
if(Regex.Matches(aa,emailflag).Count)==0本回答被提问者采纳
第2个回答  推荐于2018-03-10
static int Count(string str, string constr)
{
return System.Text.RegularExpressions.Regex.Matches(str, constr).Count;
}本回答被网友采纳
相似回答