views:

46

answers:

2

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.

+3  A: 
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.

Joel Coehoorn
+1  A: 

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

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