Users Pricing

forum

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

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

Anonymous User 4237 14 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();


1 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md