我怎樣才能讓這個更好看:讓if語句看起來更好
lblTotalWorldSize.Text = GetDirectorySize(_worldsDirectory + selectedItem) * 1024 + " kb"; // Total world size
if (Directory.Exists(_worldsDirectory + selectedItem + "\\" + selectedItem)) // World itself
{
lblWorldSize.Text = GetDirectorySize(_worldsDirectory + selectedItem + "\\" + selectedItem) * 1024 + " kb";
}
else
{
lblWorldSize.Text = "Couldn't find world.";
}
if (Directory.Exists(_worldsDirectory + selectedItem + "\\" + selectedItem + "_nether")) // Nether
{
lblNetherSize.Text = GetDirectorySize(_worldsDirectory + selectedItem + "\\" + selectedItem + "_nether") * 1024 + " kb";
}
else
{
lblWorldSize.Text = "Couldn't find world.";
}
if (Directory.Exists(_worldsDirectory + selectedItem + "\\" + selectedItem + "_the_end")) // The End
{
lblTheEndSize.Text = GetDirectorySize(_worldsDirectory + selectedItem + "\\" + selectedItem + "_the_end") * 1024 + " kb";
}
else
{
lblWorldSize.Text = "Couldn't find world.";
}
這真的看起來像一個爛攤子,我似乎無法找到任何這樣的問題。
在每個* else中賦值給'lblWorldSize'是否有錯誤? – 2012-07-27 18:22:32