CollectionExtensions Class

Definition

Provides extension methods for generic collections.

C#
public static class CollectionExtensions
Inheritance
CollectionExtensions

Methods

AddRange<T>(List<T>, ReadOnlySpan<T>)

Adds the elements of the specified span to the end of the List<T>.

AsReadOnly<T>(IList<T>)

Returns a read-only ReadOnlyCollection<T> wrapper for the specified list.

AsReadOnly<TKey,TValue>(IDictionary<TKey,TValue>)

Returns a read-only ReadOnlyDictionary<TKey,TValue> wrapper for the current dictionary.

CopyTo<T>(List<T>, Span<T>)

Copies the entire List<T> to a span.

GetValueOrDefault<TKey,TValue>(IReadOnlyDictionary<TKey,TValue>, TKey, TValue)

Tries to get the value associated with the specified key in the dictionary.

GetValueOrDefault<TKey,TValue>(IReadOnlyDictionary<TKey,TValue>, TKey)

Tries to get the value associated with the specified key in the dictionary.

InsertRange<T>(List<T>, Int32, ReadOnlySpan<T>)

Inserts the elements of a span into the List<T> at the specified index.

Remove<TKey,TValue>(IDictionary<TKey,TValue>, TKey, TValue)

Tries to remove the value with the specified key from the dictionary.

TryAdd<TKey,TValue>(IDictionary<TKey,TValue>, TKey, TValue)

Tries to add the specified key and value to the dictionary.

Applies to

Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Standard 2.1