简体   繁体   中英

how to get the property value of IEnumerable and assign it to variable in C#?

I'm using List for my data collection but decided to try IEnumerable. I'm trying to assign the value of the SHIFT property of my Attendance Class to another Datagidviwcell.

This one works for me when I'm using List;

dgview.Rows[rowindex].Cell[cellindex].value = mylist.Find(x => x.Date == datevalue).SHIFT;

how do I do this when I'm using IEnumerable instead of List;

Already solve it. Replace Find with First...

dgview.Rows[rowindex].Cell[cellindex].value = mylist.First(x => x.Date == datevalue).SHIFT;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM