Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个List<> Generic。泛型类内部有变量,例如variable1, variable2, variable3....
List<> Generic
variable1
variable2
variable3
我想创建一个泛型类的新实例,其值来自此列表中的特定项目,其中泛型的variable3 = some value
variable3 = some value
谢谢 :)
GenericClass item = yourList.FirstOrDefault(r=> r.variable3 == "somevalues");
如果您只需要选择一个符合条件的项目,那么您可以使用,