List<List<double>> Return(List<double> vector, int Z, int firstidx)
{
return vector.Reverse()
.Skip(firstidx)
.Take(Z)
.Select(i => vector.Reverse().Select(j => j != 0? i / j : 0.0).ToList())
.ToList();
}
I want to reversely
query the List
but there is some error in the .Reverse()
and it said that:
Operator '.' cannot be applied oprand of type 'void'`.
Even I create a intermediate variable
List<double> Reversevector = vector.Reverse().ToList();
So what the correct way to use .Reverse()
in linq
?
Problem is you are using List.Reverse()
method not the
Enumerable.Reverse()
you have two options, either to call it as static method or explicit casting.
Enumerable.Reverse(vector)
.Skip(firstidx)
.Take(Z)
.Select(i => Enumerable.Reverse(vector).Select(j => j != 0? i / j : 0.0).ToList())
.ToList();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With