-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed as not planned
Labels
api-suggestionEarly API idea and discussion, it is NOT ready for implementationEarly API idea and discussion, it is NOT ready for implementationarea-System.CollectionswishlistIssue we would like to prioritize, but we can't commit we will get to it yetIssue we would like to prioritize, but we can't commit we will get to it yet
Milestone
Description
Background and Motivation
As it is a best practice for API's to return ReadOnlyCollection<T> instead of List<T> etc, it would be nice to have an easy way to create an empty ReadOnlyCollection<T>. On par with Array.Empty<T>().
As it is also a best practice to return an empty collection instead of null.
Proposed API
public class ReadOnlyCollection<T>
{
public static ReadOnlyCollection<T> Empty { get; }
}Usage Examples
public ReadOnlyCollection<Stuff> FindStuff(string filter)
{
if (string.IsNullOrEmpty(filter)) return ReadOnlyCollection<Stuff>.Empty;
}SirIntruder, strangeman375, SingleAccretion, reflectronic, kronic and 10 more
Metadata
Metadata
Assignees
Labels
api-suggestionEarly API idea and discussion, it is NOT ready for implementationEarly API idea and discussion, it is NOT ready for implementationarea-System.CollectionswishlistIssue we would like to prioritize, but we can't commit we will get to it yetIssue we would like to prioritize, but we can't commit we will get to it yet