Iwrote C#代碼,它似乎正確,我錯誤告訴並非所有的代碼路徑返回一個值
public static BCSMappedTable GetMappedTable(string p_ListName)
{
List<BCSDataBase> ConnexionList = BCSManagement.GetAllDataBases();
bool found = false;
foreach (BCSDataBase connexion in ConnexionList)
{
foreach (BCSMappedTable tabList in connexion.GetMappedTables())
{
if (tabList.getListeName().Equals(p_ListName))
{
found = true;
return tabList;
}
}
}
if (found)
return new BCSMappedTable();
}
,但這個錯誤繼續出現
error : not all code paths return a value
,我沒有線索,爲什麼!我瘦,我總是返回所需的值
他們說什麼。你是否意指'如果(!發現)'接近尾聲?因爲每當'found'成立時,你已經在例程中早些返回了,所以'if(找到)'在結尾再次是多餘的。 –