views:

70

answers:

1

Hello.

I'm developing a Windows Phone application with C#.

I have an ObservableCollection defined as follows:

public class StartingPersons
{
    public string ImagePath { get; set; }
    public string Name { get; set; }

    public static ObservableCollection<StartingPersons> GetPersons()
    {
        ...
    }
}

I want to search inside the ObservableCollection returned by StartingPerons.GetPersons(); by the field NAME.

How can I do that?

Thanks.

+2  A: 

Something like:

IEnumerable<StartingPersons> matches = StartingPersons.GetPersons()
                                                .Where(p => p.Name == "...");

This isn't specific to ObservableCollection<T> though - basically you ought to look into LINQ and particularly LINQ to Objects.

Jon Skeet