使用字符串的IndexOf方法查找,找到返回正确的位置下标,未找到返回-1
举例:
string str = "我爱西欧的巴黎";
int index = str.IndexOf("爱");
if (index > -1)
{
Console.Write("找到了");
}
else {
Console.Write("未找到");
}
Console.Read();