Reputation: 196459
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.
Upvotes: 1
Views: 142
Reputation: 574
To return all objects with an Id of ten, you'll need:
list.Where(o => o.Id = 10)
Upvotes: 1
Reputation: 415705
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.
Upvotes: 3