Skip to content

[API Proposal]: IsEmpty Linq extension property #115792

Closed
@ladeak

Description

@ladeak

Background and motivation

Add IsEmpty Linq extension property as discussed here: https://build.microsoft.com/en-US/sessions/BRK114?source=sessions (t=28:40)

API Proposal

namespace System.Linq;
public static partial class Enumerable
{
    extension<T>(IEnumerable<T> source)
    {
        public bool IsEmpty { get; }
    }
}

API Usage

List<int> mycollection = new();
Console.WriteLine(mycollection.IsEmpty);

Alternative Designs (EDITED)

namespace System.Linq;
public static partial class Collections
{
    extension<T>(ICollection<T> source)
    {
        public bool IsEmpty { get; }
    }
}

Risks

Cluttering the API.

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-suggestionEarly API idea and discussion, it is NOT ready for implementationarea-System.Linq

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions