且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我如何转换IEnumerable的< T>列出< T>在C#中?

更新时间:2021-08-10 01:12:48

试试这个:

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

要知道,这基本上将创建一个从原始值集合一个新的列表,所以你的字典中的任何更改将不会自动在你的绑定控件的体现。

Be aware that that will essentially be creating a new list from the original Values collection, and so any changes to your dictionary won't automatically be reflected in your bound control.