14 Nisan 2015 Salı

Finding element(s) in List

Simple way to find an element in a List<T>

public class Foo
{
    public string ID { get; set;}
    public bool IsEnabled { get; set;}
    public bool IsDoUpdate { get; set;}
}

private List<Foo> elements = new List<Foo>();

elements.Find(x => x.ID == "1");

Filter elements

List<Foo> _s = elements .FindAll(x => x.IsEnabled && x.IsDoUpdate);

Hiç yorum yok:

Yorum Gönder