Enumerable.Range(1, 999).Select((n,i) =>{ return n*i;})
what does the “i” get in every time?
Enumerable.Range(1, 999).Select((n,i,j) =>{ return n*i*j;})
why cant I add “j”?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
Selectoverload accepting a lambda with two parameters will take the first parameter from the sequence, and the second is the index of the element.In your example
iwill always ben-1, so there is not much use of the second parameter. When working with non-trivial sequences or sequences of non-numeric types it can sometimes be an advantage to have the order number of the element available in the select expression.There is no three parameter version. That’s why
(n,i,j)doesn’t work.