c# - RemoveAll() 的目的

标签 c# .net linq

我是 Linq 的新手。根据我的理解,LINQ 应该只用于查询而不用于修改集合或数据库等。

如果是这样,微软为什么要提供 RemoveAll() 扩展?

据我所知,RemoveAll() 修改集合。

这不违背Linq的宗旨吗?

能否解释一下提供RemoveAll()的原因?

最佳答案

RemoveAll()List<T> 的一部分来自 .Net 2.0 的类。
它与 LINQ 无关;它比 LINQ 早几年。

List<T>有许多方法与 LINQ 方法做同样的事情,包括 ConvertAll , Exists , Find , FindAll , FindLast , 和 TrueForAll .

它还有 ForEach方法,is not LINQ .

关于c# - RemoveAll() 的目的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7434899/

相关文章:

c# - Linq 查询到 orderby 级别,然后是父项和子项

c# - VS 创建单元测试命令不适用于内部方法?

mysql - 在 .NET Core 2、Mac OS、使用 MySQL 的 Visual Studio for Mac 上 : ArgumentOutOfRangeException: Length cannot be less than zero

.net - 无法使用 azure Eventhub 在架构注册表中创建架构

c# - Entity Framework 6 将自定义 SQL 查询映射到实体

c# - 浏览 FindContours 方法找到的轮廓层次结构?

c# - 查找哪个模块阻塞了 UI 线程

c# Linq 对象子查询/输入

c# - Linq 查询性能,比较编译查询与非编译查询

c# - 将此 foreach 产量重写为 linq 产量?