I have a List of strings that contains 16 strings . user selects to copy items with indexes of 0,5,6,10,15 of this list to the second List .
is there any way to do this by linq ?
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.
Assuming that you already have the indices in a collection, you can use
Enumerable.ElementAtwhich just uses the indexer forIList<T>, hence it’s very efficient:If you don’t want to create a new list but copy them into an existing list: