有没有比这个函数更快的方法来比较两个字符串(使用空格作为通配符)?
public static bool CustomCompare(this string word, string mask)
{
for (int index = 0; index < mask.Length; index++)
{
if (mask[index] != ' ') && (mask[index]!= word[index]))
{
return false;
}
}
return true;
}
例子:"S nt nce"与"Sentence"比较将返回true。(需要比较的两个字符串长度相同)