Like,
List<string> a = {"a0","a1","a2","a3"};
Using LINQ, how do I take a[2] and remove it?
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.
Sounds as if you are looking for the
List.RemoveAtmethod instead:Edit:
So you want to remove the second last instead of the one with index 2, you can use the
Countproperty to find it. There’s absolutely no need to use Linq here:Demo