2 つのリストの X フィールドと Y フィールドを合計する必要がありますが、最初の Id は 2 番目の Id と同じです。
私のコード:
//Program.cs
//(...)
class Point
{
public int Id { get; set; }
public int X { get; set; }
public int Y { get; set; }
public Point(int _Id, int _X, int _Y)
{
Id = _Id;
X = _X;
Y = _Y;
}
}
//(...)
List<Point> points = new List<Point>();
List<Point> sumsXY = new List<Point>();
//sum the X and Y of two lists, but points.Id must equal to sumsXY.Id
for (int i = 0; i < objcount; i++)
{
sumsXY[points[i].Id].X = sumsXY[points[i].Id].X + points[i].X;
sumsXY[points[i].Id].Y = sumsXY[points[i].Id].Y + points[i].Y;
}
助けが必要。
デビッド