I have a list of objects
List<Objeto> lista1;
List<Objeto> lista1;
Object has an attribute X
and an attribute Y
.
I want to do the following:
List<Objeto> listaSuma =>
add the values Y
of each object and return this to the new list of objects ( objeto { X , Y + Y)
).
Obviously with a for
loop I've already done it. I want to use Linq
or Zip
, but I do not know how.
PD (objects have more variables, but you do not have to do anything with them)
List<Coordenadas> result = new List<Coordenadas>();
for (int i = 0; i < list1.Count; i++)
{
objetAux = new Coordenadas();
objetAux.Y = list1[i].Y + list12[i].Y;
objetAux.X = list1[i].X;
result.Add(objetAux);
}