//------//搜索字符串(参数1:目标字符串,参数2:之前字符串,参数3:之后字符串)----(获取两个字符串中间的字符串)
public static string Search_string(string s, string s1, string s2) //获取搜索到的数目
{
int n1, n2;
n1 = s.IndexOf(s1, 0) + s1.Length; //开始位置
n2 = s.IndexOf(s2, n1); //结束位置
return s.Substring(n1, n2 - n1); //取搜索的条数,用结束的位置-开始的位置,并返回
}
public static string Search_string(string s, string s1, string s2) //获取搜索到的数目
{
int n1, n2;
n1 = s.IndexOf(s1, 0) + s1.Length; //开始位置
n2 = s.IndexOf(s2, n1); //结束位置
return s.Substring(n1, n2 - n1); //取搜索的条数,用结束的位置-开始的位置,并返回
}
//-----------------------------------------------------------------------
indexof()用法:http://blog.youkuaiyun.com/l1976135784/article/details/8972699
本文介绍了一种在C#中实现的字符串搜索方法,该方法能够有效地从目标字符串中找到两个指定字符串之间的内容。此外,还提供了IndexOf方法的使用链接,帮助读者更好地理解和应用这一实用的编程技巧。
3407

被折叠的 条评论
为什么被折叠?



