How we can filter the object in List<> in C#?
Share
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.
Let’s say we have a
List<string>and you want only the items where the length of the string is greater than 5.The code below will return a
List<string>with the results:resultList will containt ‘world!’ and ‘large!!’.
This example uses an anonymous method. It can also be written as:
The delegate above, OnlyLargerThanFive, is also called a Predicate.