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(找到)'在结尾再次是多余的。 –