I have a List<> Generic
.The generic class has variables inside such as variable1
, variable2
, variable3
....
I want to create a new instance of a generic class with values coming from a specific item in this list where generic's variable3 = some value
Thanks :)
GenericClass item = yourList.FirstOrDefault(r=> r.variable3 == "somevalues");
If you only need to select a single item which met the criteria, then you can use,
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.