Skip to content
Backported read-only collection interfaces and extensions/adapters around them
Branch: master
Clone or download

README.md

ReadOnlyCollections

Backported read-only collection interfaces and extensions/adapters around them.

This repository contains two projects:

ReadOnlyCollectionsInterfaces is a backport of the new IReadOnly* interfaces in .NET 4.5, making them available to .NET 2.0 up to .NET 4.0

The interfaces are:

ReadOnlyCollectionsExtensions provides minimal extension methods around these interfaces, converting or exposing IList as IReadOnlyList, etc These are designed to be similar to System.Linq.Enumerable.ToList(), etc

IReadOnlyCollection<T> AsReadOnlyCollection<T>(this ICollection<T> source)
IReadOnlyList<T> AsReadOnlyList<T>(this IList<T> source)
IReadOnlyList<T> ToReadOnlyList<T>(this IEnumerable<T> source)
IReadOnlyDictionary<TKey, TValue> ToReadOnlyDictionary<TSource, TKey, TValue>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TValue> valueSelector, IEqualityComparer<TKey> comparer)
IReadOnlyDictionary<TKey, TValue> ToReadOnlyDictionary<TSource, TKey, TValue>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TValue> valueSelector)
IReadOnlyDictionary<TKey, TValue> ToReadOnlyDictionary<TKey, TValue>(this IEnumerable<KeyValuePair<TKey, TValue>> dict)
IReadOnlyDictionary<TKey, TValue> ToReadOnlyDictionary<TKey, TValue>(this IEnumerable<KeyValuePair<TKey, TValue>> dict, IEqualityComparer<TKey> comparer)
IReadOnlyDictionary<TKey, TValue> AsReadOnlyDictionary<TKey, TValue>(this IDictionary<TKey, TValue> dict)

Binaries available on NuGet.

You can’t perform that action at this time.