错误消息
“method”:并非所有的代码路径都返回值
Code
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace __7
6{
7 class add1
8
{
9 static int add(int a,int b)
10
{
11 return a + b;
12 }
13 public static int Main()
14
{
15 int i = add(5,10);
16 Console.WriteLine(i);
17 Console.ReadLine();
18 retrun 0
19
20 }
21
22 }
23
24}
25
查找相关资料后 加上retrun 0 调试通过
要看一下main方法前有没有要求要有返回值!void main()应该不要,int main()要.
在 int main()中,return 0表示返回一个整形,
正常结束,而在一般函数体中 return 0 表示不正常的结束。
当把public int Main()改为 public void Main()
去掉retrun 0;通过