Given:
List<int> list = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
How do I implement the following code?
var list2 = list.skip(2).take(5);
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.
Your sample code will work as long as you include
System.Linqin your using statements (and fix your method names.Skip(2)and.Take(5)).The reason your code did not work out of the box is that
.Skipand.Takeare extension methods (as opposed to methods defined in the List class) found in the ‘System.Linq’ namespace.