gpt4 book ai didi

Linq RemoveFirst 等效项

转载 作者:行者123 更新时间:2023-12-01 16:11:00 25 4
gpt4 key购买 nike

我正在寻找 Linq RemoveFirst(Predicate<T> match)但只能找到RemoveAll .

我知道我可以编写自己的扩展方法,但想知道是否已经存在具有不同名称的等效函数,或者是否存在实现相同结果的简单方法。

最佳答案

像这样:

list.RemoveAt(list.FindIndex(x => thingy));

如果没有找到项目,将抛出异常。

请注意,这与 LINQ 无关,只能通过 List<T> 完成.

关于Linq RemoveFirst 等效项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4379325/

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