Skip to content

Why IList does not have the method signature RemoveAll? #2199

@devdouglasferreira

Description

@devdouglasferreira

public class List : ICollection, IEnumerable, IEnumerable, IList, IReadOnlyCollection, IReadOnlyList, ICollection, IList

public interface IList : ICollection, IEnumerable, IEnumerable

IList only have Remove() and RemoveAt()... Wouldn't be more interesting put the RemoveAll() method signature in IList for access it?? Neither ICollection or IEnumerable has these methods signatures. Because if I want to remove all items under a specific condition through IList interface I have to transform to a List first

// Enderecos is IList type
       var listEnderecos = clienteModel.Enderecos.ToList();
            listEnderecos.RemoveAll(p => p == null);
            clienteModel.Enderecos = listEnderecos;

With RemoveAll() method in IList

// Enderecos is IList type
       clienteModel.Enderecos.RemoveAll(p => p == null);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions