且构网

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

如何在BlindingList C#WinForms中查找对象

更新时间:2023-12-05 17:33:52

如果要通过其ID查找对象,例如15 = 5
然后:

If you want to find an object by it''s id, for example 15 = 5
then:

var foundObject = myList.Where(o=>o.propertyID == 5).First()



更好:

假设对象是Person的实例:



And Better:

Imagin the object is an instance of Person:

Person person;

var foundObject = myList.Where(o=>o.propertyID == 5);

if(foundObject.Count()>0)
   person = foundObject.First();