【发布时间】:2023-03-26 00:13:01
【问题描述】:
static class Util
{
static Random ran = new Random();
public static List<Point3d> RandomptGenerator(int num)
{
List <Point3d> ptList = new List<Point3d>();
int count = num;
for (int i = 0;i < count;i++)
{
for (int j = 0;j < count;j++)
{
double x = i;
double y = j;
x = ran.Next(0, 40);
y = ran.Next(0, 30);
ptList.Add(new Point3d(x, y, 0.0));
return ptList;
}
}
}
}
大家好,
当我尝试编译此代码时出现以下错误:
- 检测到无法访问的代码
- 并非所有代码路径都返回值
我无法弄清楚为什么会发生这种情况......任何帮助将不胜感激。 谢谢!
【问题讨论】:
-
return ptList;应该在方法的末尾 -
看看你的return语句在哪里
标签: c#