我有一个大约2000个字符的字符串缓冲区,如果它包含一个特定的字符串,需要检查缓冲区.
将针对每个webrequest在ASP.NET 2.0 webapp中进行检查.
有谁知道String.Contains方法是否比String.IndexOf方法表现更好?
// 2000 characters in s1, search token in s2
string s1 = "Many characters. The quick brown fox jumps over the lazy dog";
string s2 = "fox";
bool b;
b = s1.Contains(s2);
int i;
i = s1.IndexOf(s2);
Run Code Online (Sandbox Code Playgroud)