C#检测字符串中是否含有指定字符
- 使用contains(contains的返回值为true或false)
bool isContain=StringA.Contain("llo");
- 使用IndexOf方法(IndexOfIndexOf方法是存在则返回所在的索引开始位置,否则返回-1。)
string StringA="Hello World";
var index=StringA.IndexOf("llo");
参考文章:https://www.50bit.cn/News/Index/5265.html