1

i have a objectA

 public class objectA
 {
     public int Id;
     public string Name;
 }

i have a list of objectA

List<objectA> list;

i want to find in the list any objectA with Id = 10;

is there linq syntax for this or do i simply have to write a loop here.

2 Answers 2

3
list.Where(o => o.Id == 10);

Remember: you can chain those method calls, or you can use the IEnumerable returned here for things like databinding.

Sign up to request clarification or add additional context in comments.

Comments

1

To return all objects with an Id of ten, you'll need:

list.Where(o => o.Id = 10)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.