Table of Contents

Class CollectionExtensions

Namespace
CarinaStudio.Collections
Assembly
CarinaStudio.AppBase.Core.dll

Extensions for ICollection<T>.

public static class CollectionExtensions
Inheritance
CollectionExtensions
Inherited Members

Methods

AddAll<T>(ICollection<T>, IEnumerable<T>)

Add all given elements to collection.

public static void AddAll<T>(this ICollection<T> collection, IEnumerable<T> elements)

Parameters

collection ICollection<T>

Collection.

elements IEnumerable<T>

Elements to add.

Type Parameters

T

Type of element of collection.

IsEmpty<T>(ICollection<T>)

Check whether given collection is empty or not.

public static bool IsEmpty<T>(this ICollection<T> collection)

Parameters

collection ICollection<T>

Collection to check.

Returns

bool

True if collection is empty.

Type Parameters

T

Type of element of collection.

IsEmpty<T>(IReadOnlyCollection<T>)

Check whether given collection is empty or not.

public static bool IsEmpty<T>(this IReadOnlyCollection<T> collection)

Parameters

collection IReadOnlyCollection<T>

Collection to check.

Returns

bool

True if collection is empty.

Type Parameters

T

Type of element of collection.

IsNotEmpty<T>(ICollection<T>?)

Check whether given collection is not empty or not.

public static bool IsNotEmpty<T>(this ICollection<T>? collection)

Parameters

collection ICollection<T>

Collection to check.

Returns

bool

True if collection is not empty.

Type Parameters

T

Type of element of collection.

IsNotEmpty<T>(IReadOnlyCollection<T>?)

Check whether given collection is not empty or not.

public static bool IsNotEmpty<T>(this IReadOnlyCollection<T>? collection)

Parameters

collection IReadOnlyCollection<T>

Collection to check.

Returns

bool

True if collection is not empty.

Type Parameters

T

Type of element of collection.

IsNullOrEmpty<T>(ICollection<T>?)

Check whether given collection is null/empty or not.

public static bool IsNullOrEmpty<T>(this ICollection<T>? collection)

Parameters

collection ICollection<T>

Collection to check.

Returns

bool

True if collection is null or empty.

Type Parameters

T

Type of element of collection.

IsNullOrEmpty<T>(IReadOnlyCollection<T>?)

Check whether given collection is null/empty or not.

public static bool IsNullOrEmpty<T>(this IReadOnlyCollection<T>? collection)

Parameters

collection IReadOnlyCollection<T>

Collection to check.

Returns

bool

True if collection is null or empty.

Type Parameters

T

Type of element of collection.

RemoveAll<T>(ICollection<T>, Predicate<T>)

Remove elements which match the given condition from collection.

public static int RemoveAll<T>(this ICollection<T> collection, Predicate<T> predicate)

Parameters

collection ICollection<T>

Collection.

predicate Predicate<T>

Function to check condition.

Returns

int

Number of removed elements.

Type Parameters

T

Type of element of collection.