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

注意我说的是“方法”,超过3行代码的就别回了
2024-11-25 21:10:39
推荐回答(3个)
回答(1):

show.EndsWith("你好链胡嫌");
即为字符show 内,是"你做银好"

show.Length;
show字符内的个数棚手

比如:show="123456"

show.Length=6

回答(2):

string aa="隐脊 abcd6789@21cn.com"陆携核;
方法1:aa.IndexOf ("b",1,);
方法2:有需要用正则表达式
string emailflag = "早掘@";
if(Regex.Matches(aa,emailflag).Count)==0

回答(3):

static int Count(string str, string constr)
{
return System.Text.RegularExpressions.Regex.Matches(str, constr).Count;
}