更新:2007 年 11 月
错误消息
“method”:并非所有的代码路径都返回值
返回值的方法必须在所有代码路径中都具有 return 语句。有关更多信息,请参见方法(C# 编程指南)。
下面的示例生成 CS0161:
// CS0161.cs
public class Test
{
public static int Main() // CS0161
{
int i = 10;
if (i < 10)
{
return i;
}
else
{
// uncomment the following line to resolve
// return 1;
}
}
}