在此方法之后,我的列表计数返回0,而不应该。所有的调试都是正确的,他们都不是null或者其他东西。我正在使用Unity。 有谁知道问题在哪里?通过for循环添加值后返回0列表 - c#
List<Coordinates> FillCoordinates()
{
List<Coordinates> coordinatesList = new List<Coordinates>();
Debug.Log(minLenght);
Debug.Log(maxLenght);
Debug.Log(heights.Count);
for (int i = minLenght; i > maxLenght; i++)
{
for (int j = 0; j < heights.Count; j++)
{
coordinatesList.Add(new Coordinates(i, heights[j]));
}
}
return coordinatesList;
}
坐标类:
public class Coordinates
{
public int lenght;
public float height;
public Coordinates(int lenght_, float height_)
{
lenght = lenght_;
height = height_;
}
}
'对(INT I = minLenght; I ** <** maxLenght;我++)'' –
是Lenght'一个错字。应该是'长度' – Itsik