gpt4 book ai didi

c# - 如何从 IReadOnlyList 中查找项目?

转载 作者:行者123 更新时间:2023-12-05 09:07:14 26 4
gpt4 key购买 nike

我将属性类型从 List<T> 更改为至 IReadOnlyList<T> ,但我使用的是 List<T>.Find()方法,现在编译器给出 error CS1061: 'IReadOnlyList<T>' does not contain a definition for 'Find' and no accessible extension method 'Find' accepting a first argument of type 'IReadOnlyList<T>' could be found (are you missing a using directive or an assembly reference?) .如何从 IReadOnlyList<T> 中找到项目?

最佳答案

IReadOnlyList<T>工具 IEnumerable<T> , 你可以使用 IEnumerable<T>.FirstOrDefault()替换 List<T>.Find() .

关于c# - 如何从 IReadOnlyList<T> 中查找项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65253869/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com