how do access previous item in list using linQ?

I have:

List<int> A  = new List<int>(){1,2,3,4,5,6};

List<int> m=new List<int>();
for(int i=1;i<A.count;i++)
{
int j=A[i]+A[i-1];
m.add(j);
}

how can i do this same operation using LinQ?

16
задан Juan Castillo 8 November 2019 в 21:24
поделиться