[英]Select a specific Item from a list<generic> by one of its variable
I have a List<> Generic
.The generic class has variables inside such as variable1
, variable2
, variable3
.... 我有一个
List<> Generic
.generic类内部有变量,例如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
我想创建一个泛型类的新实例,其值来自此列表中的特定项,其中泛型的
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, 如果您只需要选择一个符合条件的项目,则可以使用,
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.