1130.md
February 3, 2022 ยท View on GitHub
You generally don't want callers to be able to change an internal collection, so don't return arrays, lists or other collection classes directly. Instead, return an IEnumerable<T>, IAsyncEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, IReadOnlySet<T> or IReadOnlyDictionary<TKey, TValue>.
Exception: Immutable collections such as ImmutableArray<T>, ImmutableList<T> and ImmutableDictionary<TKey, TValue> prevent modifications from the outside and are thus allowed.