这种加速方法的最佳重写是什么?
public static bool EndsWith(string line, string term)
{
bool rb = false;
int lengthOfTerm = term.Length;
string endOfString = StringHelpers.RightString(line, lengthOfTerm);
if (StringHelpers.AreEqual(term, endOfString))
{
return true;
}
else
{
rb = false;
}
if (line == term)
{
rb = true;
}
return rb;
}
Run Code Online (Sandbox Code Playgroud)
Fre*_*örk 24
也许我完全忽略了这一点,但我会自发地去寻找String.EndsWith方法.
您可能希望删除该方法而不是重写它...
public static bool EndsWith(string line, string term)
{
return line.EndsWith(term);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
386 次 |
| 最近记录: |