Filtering a list of objects with a certain attribute

c#

Solution

You can use LINQ:

var results = Objects.Where(o => o.Description == "test");

On a side note, realize that `Object` is a very poor choice of names for a class, and won't even compile as-is... I'd recommend choosing more appropriate names, and following standard capitalization conventions for C#.

Problem

``` class Object { public int ID {get; set;} public string description {get; set;} } ``` If I have a `List<Object> Objects` populated with various objects, and I want to find objects whose description is something particular, how would I do that? ``` find every Object in Objects whose description == "test" ```

Original source