夥計們, 我string.IsNullOrWhiteSpace望着的實施:.NET string.IsNullOrWhiteSpace實施
http://typedescriptor.net/browse/types/9331-System.String
下面是執行:
public static bool IsNullOrWhiteSpace(string value)
{
if (value == null)
{
return true;
}
for (int i = 0; i < value.Length; i++)
{
if (char.IsWhiteSpace(value[i]))
{
}
else
{
goto Block_2;
}
}
goto Block_3;
Block_2:
return false;
Block_3:
return true;
}
問:難道不是這過於複雜嗎?以下實現不能完成相同的工作並且更容易上手:
bool IsNullOrWhiteSpace(string value)
{
if(value == null)
{
return true;
}
for(int i = 0; i < value.Length;i++)
{
if(!char.IsWhiteSpace(value[i]))
{
return false;
}
}
return true;
}
此實現是否不正確?它是否有性能損失?
這是本質它在做什麼 - 你是** **不看真正的源代碼,正是從反射 – BrokenGlass 2012-04-20 17:57:39
收集你的意思是字符串或炭? – 2012-04-20 17:57:40