forum

Home / DeveloperSection / Forums / How can I convert IEnumerable<T> to List<T> in C#?

How can I convert IEnumerable<T> to List<T> in C#?

Anonymous User356014-Nov-2013

I am using LINQ to query a generic dictionary and then use the result as the datasource for my ListView.

Dictionary<Guid, Record> dict = GetAllRecords();

List<Record> searchResults = new List<Record>();

var matches = dict.Values.Where(rec => rec.Name == "foo");

foreach (Record rec in matches)

    searchResults.Add(rec);

myListView.DataSource = searchResults;

myListView.DataBind();


Updated on 14-Nov-2013
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By