Show / Hide Table of Contents

Class CollectionHelpers

Includes useful extension methods for common collections and enumerations.

Inheritance
object
CollectionHelpers
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: TheXDS.MCART.Helpers
Assembly: MCART.dll
Syntax
public static class CollectionHelpers

Methods

| Edit this page View Source

AllEmpty(IAsyncEnumerable<string?>)

Determines if all the specified strings are either null, Empty or a string consisting only of whitespaces.

Declaration
public static Task<bool> AllEmpty(this IAsyncEnumerable<string?> stringCollection)
Parameters
Type Name Description
IAsyncEnumerable<string> stringCollection

Async enumeration of strings to be checked.

Returns
Type Description
Task<bool>

true all of the strings are either null, Empty or a string consisting only of whitespaces; or false otherwise.

Exceptions
Type Condition
ArgumentNullException

Thrown if stringCollection is null.

| Edit this page View Source

AllEmpty(IEnumerable<string?>)

Determines if all the specified strings are either null, Empty or a string consisting only of whitespaces.

Declaration
public static bool AllEmpty(this IEnumerable<string?> stringCollection)
Parameters
Type Name Description
IEnumerable<string> stringCollection

Enumeration of strings to be checked.

Returns
Type Description
bool

true all of the strings are either null, Empty or a string consisting only of whitespaces; or false otherwise.

Exceptions
Type Condition
ArgumentNullException

Thrown if stringCollection is null.

| Edit this page View Source

And(IEnumerable<bool>)

Applies the AND operator to a collection of bool values.

Declaration
public static bool And(this IEnumerable<bool> collection)
Parameters
Type Name Description
IEnumerable<bool> collection

Collection to apply the operation from.

Returns
Type Description
bool

The result of applying the AND operator to all bits in the collection.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

InvalidOperationException

Thrown if collection does not contain any elements.

| Edit this page View Source

And(IEnumerable<byte>)

Applies the AND operator to a collection of bool values.

Declaration
public static byte And(this IEnumerable<byte> collection)
Parameters
Type Name Description
IEnumerable<byte> collection

Collection to apply the operation from.

Returns
Type Description
byte

The result of applying the AND operator to all bits in the collection.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

InvalidOperationException

Thrown if collection does not contain any elements.

| Edit this page View Source

And(IEnumerable<char>)

Applies the AND operator to a collection of char values.

Declaration
public static char And(this IEnumerable<char> collection)
Parameters
Type Name Description
IEnumerable<char> collection

Collection to apply the operation from.

Returns
Type Description
char

The result of applying the AND operator to all bits in the collection.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

InvalidOperationException

Thrown if collection does not contain any elements.

| Edit this page View Source

And(IEnumerable<short>)

Applies the AND operator to a collection of short values.

Declaration
public static short And(this IEnumerable<short> collection)
Parameters
Type Name Description
IEnumerable<short> collection

Collection to apply the operation from.

Returns
Type Description
short

The result of applying the AND operator to all bits in the collection.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

InvalidOperationException

Thrown if collection does not contain any elements.

| Edit this page View Source

And(IEnumerable<int>)

Applies the AND operator to a collection of int values.

Declaration
public static int And(this IEnumerable<int> collection)
Parameters
Type Name Description
IEnumerable<int> collection

Collection to apply the operation from.

Returns
Type Description
int

The result of applying the AND operator to all bits in the collection.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

InvalidOperationException

Thrown if collection does not contain any elements.

| Edit this page View Source

And(IEnumerable<long>)

Applies the AND operator to a collection of long values.

Declaration
public static long And(this IEnumerable<long> collection)
Parameters
Type Name Description
IEnumerable<long> collection

Collection to apply the operation from.

Returns
Type Description
long

The result of applying the AND operator to all bits in the collection.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

InvalidOperationException

Thrown if collection does not contain any elements.

| Edit this page View Source

And(IEnumerable<sbyte>)

Applies the AND operator to a collection of sbyte values.

Declaration
[CLSCompliant(false)]
public static sbyte And(this IEnumerable<sbyte> collection)
Parameters
Type Name Description
IEnumerable<sbyte> collection

Collection to apply the operation from.

Returns
Type Description
sbyte

The result of applying the AND operator to all bits in the collection.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

InvalidOperationException

Thrown if collection does not contain any elements.

| Edit this page View Source

And(IEnumerable<ushort>)

Applies the AND operator to a collection of ushort values.

Declaration
[CLSCompliant(false)]
public static ushort And(this IEnumerable<ushort> collection)
Parameters
Type Name Description
IEnumerable<ushort> collection

Collection to apply the operation from.

Returns
Type Description
ushort

The result of applying the AND operator to all bits in the collection.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

InvalidOperationException

Thrown if collection does not contain any elements.

| Edit this page View Source

And(IEnumerable<uint>)

Applies the AND operator to a collection of uint values.

Declaration
[CLSCompliant(false)]
public static uint And(this IEnumerable<uint> collection)
Parameters
Type Name Description
IEnumerable<uint> collection

Collection to apply the operation from.

Returns
Type Description
uint

The result of applying the AND operator to all bits in the collection.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

InvalidOperationException

Thrown if collection does not contain any elements.

| Edit this page View Source

And(IEnumerable<ulong>)

Applies the AND operator to a collection of ulong values.

Declaration
[CLSCompliant(false)]
public static ulong And(this IEnumerable<ulong> collection)
Parameters
Type Name Description
IEnumerable<ulong> collection

Collection to apply the operation from.

Returns
Type Description
ulong

The result of applying the AND operator to all bits in the collection.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

InvalidOperationException

Thrown if collection does not contain any elements.

| Edit this page View Source

AnyEmpty(IAsyncEnumerable<string?>)

Determines if any the specified strings are either null, Empty or a string consisting only of whitespaces.

Declaration
public static Task<bool> AnyEmpty(this IAsyncEnumerable<string?> stringCollection)
Parameters
Type Name Description
IAsyncEnumerable<string> stringCollection

Async enumeration of strings to be checked.

Returns
Type Description
Task<bool>

true any of the strings are either null, Empty or a string consisting only of whitespaces; or false otherwise.

Exceptions
Type Condition
ArgumentNullException

Thrown if stringCollection is null.

| Edit this page View Source

AnyEmpty(IEnumerable<string?>)

Determines if any the specified strings are either null, Empty or a string consisting only of whitespaces.

Declaration
public static bool AnyEmpty(this IEnumerable<string?> stringCollection)
Parameters
Type Name Description
IEnumerable<string> stringCollection

Enumeration of strings to be checked.

Returns
Type Description
bool

true any of the strings are either null, Empty or a string consisting only of whitespaces; or false otherwise.

Exceptions
Type Condition
ArgumentNullException

Thrown if stringCollection is null.

| Edit this page View Source

AnyEmpty(IEnumerable<string?>, out IEnumerable<int>)

Determines if any the specified strings are either null, Empty or a string consisting only of whitespaces.

Declaration
public static bool AnyEmpty(this IEnumerable<string?> stringCollection, out IEnumerable<int> index)
Parameters
Type Name Description
IEnumerable<string> stringCollection

Enumeration of strings to be checked.

IEnumerable<int> index

Out parameter. Indices of the items that were null, empty or a string consisting only of whitespaces.

Returns
Type Description
bool

true any of the strings are either null, Empty or a string consisting only of whitespaces; or false otherwise.

Exceptions
Type Condition
ArgumentNullException

Thrown if stringCollection is null.

| Edit this page View Source

AnyEmpty(IEnumerable<string?>, out int)

Determines if any the specified strings are either null, Empty or a string consisting only of whitespaces.

Declaration
public static bool AnyEmpty(this IEnumerable<string?> stringCollection, out int firstIndex)
Parameters
Type Name Description
IEnumerable<string> stringCollection

Enumeration of strings to be checked.

int firstIndex

Out parameter. Index of the first item that was null, empty or a string consisting only of whitespaces.

Returns
Type Description
bool

true any of the strings are either null, Empty or a string consisting only of whitespaces; or false otherwise.

Exceptions
Type Condition
ArgumentNullException

Thrown if stringCollection is null.

| Edit this page View Source

AreAllNull(IEnumerable<object?>)

Determines if all the specified strings are either null, Empty or a string consisting only of whitespaces.

Declaration
public static bool AreAllNull(this IEnumerable<object?> collection)
Parameters
Type Name Description
IEnumerable<object> collection

Enumeration of strings to be checked.

Returns
Type Description
bool

true any of the strings are either null, Empty or a string consisting only of whitespaces; or false otherwise.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

| Edit this page View Source

IsAnyNull(IEnumerable<object?>?)

Determines if any of the specified objects is null.

Declaration
public static bool IsAnyNull(this IEnumerable<object?>? collection)
Parameters
Type Name Description
IEnumerable<object> collection

Collection of objects to be checked.

Returns
Type Description
bool

true if any of the specified objects is null, false otherwise.

| Edit this page View Source

IsAnyNull(IEnumerable<object?>, out IEnumerable<int>)

Determines if any of the specified objects is null.

Declaration
public static bool IsAnyNull(this IEnumerable<object?> collection, out IEnumerable<int> index)
Parameters
Type Name Description
IEnumerable<object> collection

Collection of objects to be checked.

IEnumerable<int> index

Out parameter. Indices of the objects that were null.

Returns
Type Description
bool

true if any of the specified objects is null, false otherwise.

| Edit this page View Source

IsAnyNull(IEnumerable<object?>, out int)

Determines if any of the specified objects is null.

Declaration
public static bool IsAnyNull(this IEnumerable<object?> collection, out int firstIndex)
Parameters
Type Name Description
IEnumerable<object> collection

Collection of objects to be checked.

int firstIndex

Out parameter. Index of the first object that was null.

Returns
Type Description
bool

true if any of the specified objects is null, false otherwise.

| Edit this page View Source

NotEmpty(IAsyncEnumerable<string?>)

Enumerates all non-empty strings in a collection.

Declaration
public static IAsyncEnumerable<string> NotEmpty(this IAsyncEnumerable<string?> stringCollection)
Parameters
Type Name Description
IAsyncEnumerable<string> stringCollection

String collection to filter.

Returns
Type Description
IAsyncEnumerable<string>

An enumeration of all non-empty strings in the collection.

| Edit this page View Source

NotEmpty(IEnumerable<string?>)

Enumerates all non-empty strings in a collection.

Declaration
public static IEnumerable<string> NotEmpty(this IEnumerable<string?> stringCollection)
Parameters
Type Name Description
IEnumerable<string> stringCollection

String collection to filter.

Returns
Type Description
IEnumerable<string>

An enumeration of all non-empty strings in the collection.

| Edit this page View Source

Or(IEnumerable<bool>)

Applies the OR operator to a collection of bool values.

Declaration
public static bool Or(this IEnumerable<bool> collection)
Parameters
Type Name Description
IEnumerable<bool> collection

Collection to apply the operation from.

Returns
Type Description
bool

The result of applying the OR operator to all bits in the collection.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

| Edit this page View Source

Or(IEnumerable<byte>)

Applies the OR operator to a collection of byte values.

Declaration
public static byte Or(this IEnumerable<byte> collection)
Parameters
Type Name Description
IEnumerable<byte> collection

Collection to apply the operation from.

Returns
Type Description
byte

The result of applying the OR operator to all bits in the collection.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

| Edit this page View Source

Or(IEnumerable<char>)

Applies the OR operator to a collection of char values.

Declaration
public static char Or(this IEnumerable<char> collection)
Parameters
Type Name Description
IEnumerable<char> collection

Collection to apply the operation from.

Returns
Type Description
char

The result of applying the OR operator to all bits in the collection.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

| Edit this page View Source

Or(IEnumerable<short>)

Applies the OR operator to a collection of short values.

Declaration
public static short Or(this IEnumerable<short> collection)
Parameters
Type Name Description
IEnumerable<short> collection

Collection to apply the operation from.

Returns
Type Description
short

The result of applying the OR operator to all bits in the collection.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

| Edit this page View Source

Or(IEnumerable<int>)

Applies the OR operator to a collection of int values.

Declaration
public static int Or(this IEnumerable<int> collection)
Parameters
Type Name Description
IEnumerable<int> collection

Collection to apply the operation from.

Returns
Type Description
int

The result of applying the OR operator to all bits in the collection.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

| Edit this page View Source

Or(IEnumerable<long>)

Applies the OR operator to a collection of long values.

Declaration
public static long Or(this IEnumerable<long> collection)
Parameters
Type Name Description
IEnumerable<long> collection

Collection to apply the operation from.

Returns
Type Description
long

The result of applying the OR operator to all bits in the collection.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

| Edit this page View Source

Or(IEnumerable<sbyte>)

Applies the OR operator to a collection of sbyte values.

Declaration
[CLSCompliant(false)]
public static sbyte Or(this IEnumerable<sbyte> collection)
Parameters
Type Name Description
IEnumerable<sbyte> collection

Collection to apply the operation from.

Returns
Type Description
sbyte

The result of applying the OR operator to all bits in the collection.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

| Edit this page View Source

Or(IEnumerable<ushort>)

Applies the OR operator to a collection of ushort values.

Declaration
[CLSCompliant(false)]
public static ushort Or(this IEnumerable<ushort> collection)
Parameters
Type Name Description
IEnumerable<ushort> collection

Collection to apply the operation from.

Returns
Type Description
ushort

The result of applying the OR operator to all bits in the collection.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

| Edit this page View Source

Or(IEnumerable<uint>)

Applies the OR operator to a collection of uint values.

Declaration
[CLSCompliant(false)]
public static uint Or(this IEnumerable<uint> collection)
Parameters
Type Name Description
IEnumerable<uint> collection

Collection to apply the operation from.

Returns
Type Description
uint

The result of applying the OR operator to all bits in the collection.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

| Edit this page View Source

Or(IEnumerable<ulong>)

Applies the OR operator to a collection of ulong values.

Declaration
[CLSCompliant(false)]
public static ulong Or(this IEnumerable<ulong> collection)
Parameters
Type Name Description
IEnumerable<ulong> collection

Collection to apply the operation from.

Returns
Type Description
ulong

The result of applying the OR operator to all bits in the collection.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

| Edit this page View Source

ToPercent(IAsyncEnumerable<double>, double, double)

Converts the values in a numerical collection to their respective values as percentages.

Declaration
public static IAsyncEnumerable<double> ToPercent(this IAsyncEnumerable<double> collection, double min, double max)
Parameters
Type Name Description
IAsyncEnumerable<double> collection

Collection to be converted.

double min

Value that represents 0%.

double max

Value that represents 100%.

Returns
Type Description
IAsyncEnumerable<double>

A double collection of values as percentages.

Exceptions
Type Condition
ArgumentNullException

Thrown collection is null.

InvalidOperationException

Thrown if min and max are equal.

| Edit this page View Source

ToPercent(IAsyncEnumerable<double>, in double)

Converts the values in a numerical collection to their respective values as percentages.

Declaration
public static IAsyncEnumerable<double> ToPercent(this IAsyncEnumerable<double> collection, in double max)
Parameters
Type Name Description
IAsyncEnumerable<double> collection

Collection to be converted.

double max

Value that represents 100%.

Returns
Type Description
IAsyncEnumerable<double>

A double collection of values as percentages.

Exceptions
Type Condition
ArgumentNullException

Thrown collection is null.

InvalidOperationException

Thrown if max is equal to zero.

| Edit this page View Source

ToPercent(IAsyncEnumerable<float>, float, float)

Converts the values in a numerical collection to their respective values as percentages.

Declaration
public static IAsyncEnumerable<float> ToPercent(this IAsyncEnumerable<float> collection, float min, float max)
Parameters
Type Name Description
IAsyncEnumerable<float> collection

Collection to be converted.

float min

Value that represents 0%.

float max

Value that represents 100%.

Returns
Type Description
IAsyncEnumerable<float>

A double collection of values as percentages.

Exceptions
Type Condition
ArgumentNullException

Thrown collection is null.

InvalidOperationException

Thrown if min and max are equal.

| Edit this page View Source

ToPercent(IAsyncEnumerable<float>, in float)

Converts the values in a numerical collection to their respective values as percentages.

Declaration
public static IAsyncEnumerable<float> ToPercent(this IAsyncEnumerable<float> collection, in float max)
Parameters
Type Name Description
IAsyncEnumerable<float> collection

Collection to be converted.

float max

Value that represents 100%.

Returns
Type Description
IAsyncEnumerable<float>

A double collection of values as percentages.

Exceptions
Type Condition
ArgumentNullException

Thrown collection is null.

InvalidOperationException

Thrown if max is equal to zero.

| Edit this page View Source

ToPercent(IEnumerable<double>)

Converts the values of a collection of elements double to percentages.

Declaration
public static IEnumerable<double> ToPercent(this IEnumerable<double> collection)
Parameters
Type Name Description
IEnumerable<double> collection

Collection to process.

Returns
Type Description
IEnumerable<double>

A collection of double with its values expressed as percentages.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

InvalidOperationException

Thrown if the minimum and maximum values of the collection are equal.

| Edit this page View Source

ToPercent(IEnumerable<double>, double, double)

Converts the values in a numerical collection to their respective values as percentages.

Declaration
public static IEnumerable<double> ToPercent(this IEnumerable<double> collection, double min, double max)
Parameters
Type Name Description
IEnumerable<double> collection

Collection to be converted.

double min

Value that represents 0%.

double max

Value that represents 100%.

Returns
Type Description
IEnumerable<double>

A double collection of values as percentages.

Exceptions
Type Condition
ArgumentNullException

Thrown collection is null.

InvalidOperationException

Thrown if min and max are equal.

| Edit this page View Source

ToPercent(IEnumerable<double>, in double)

Converts the values of a collection of elements double to percentages.

Declaration
public static IEnumerable<double> ToPercent(this IEnumerable<double> collection, in double max)
Parameters
Type Name Description
IEnumerable<double> collection

Collection to process.

double max

Value that will represent 100%.

Returns
Type Description
IEnumerable<double>

A collection of double with its values expressed as percentages.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

InvalidOperationException

Thrown if the minimum value of the collection and max are equal.

| Edit this page View Source

ToPercent(IEnumerable<float>)

Converts the values of a collection of elements float to percentages.

Declaration
public static IEnumerable<float> ToPercent(this IEnumerable<float> collection)
Parameters
Type Name Description
IEnumerable<float> collection

Collection to process.

Returns
Type Description
IEnumerable<float>

A collection of float with its values expressed as percentages.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

InvalidOperationException

Thrown if the minimum and maximum values of the collection are equal.

| Edit this page View Source

ToPercent(IEnumerable<float>, in bool)

Converts the values of a collection of elements float to percentages.

Declaration
public static IEnumerable<float> ToPercent(this IEnumerable<float> collection, in bool baseZero)
Parameters
Type Name Description
IEnumerable<float> collection

Collection to process.

bool baseZero

If true, the base of percentage is zero; otherwise, the minimum value within the collection will be used.

Returns
Type Description
IEnumerable<float>

A collection of float with its values expressed as percentages.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

InvalidOperationException

Thrown if the minimum and maximum values of the collection are equal.

| Edit this page View Source

ToPercent(IEnumerable<float>, float, float)

Converts the values of a collection of elements float to percentages.

Declaration
public static IEnumerable<float> ToPercent(this IEnumerable<float> collection, float min, float max)
Parameters
Type Name Description
IEnumerable<float> collection

Collection to process.

float min

Value that will represent 0%.

float max

Value that will represent 100%.

Returns
Type Description
IEnumerable<float>

A collection of float with its values expressed as percentages.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

InvalidOperationException

Thrown if min and max are equal.

| Edit this page View Source

ToPercent(IEnumerable<float>, in float)

Converts the values of a collection of elements float to percentages.

Declaration
public static IEnumerable<float> ToPercent(this IEnumerable<float> collection, in float max)
Parameters
Type Name Description
IEnumerable<float> collection

Collection to process.

float max

Value that will represent 100%.

Returns
Type Description
IEnumerable<float>

A collection of float with its values expressed as percentages.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

InvalidOperationException

Thrown if the minimum value of the collection and max are equal.

| Edit this page View Source

ToPercentAbsolute(IEnumerable<double>)

Converts the values in a numerical collection to their respective values as percentages.

Declaration
public static IEnumerable<double> ToPercentAbsolute(this IEnumerable<double> collection)
Parameters
Type Name Description
IEnumerable<double> collection

Collection to be converted.

Returns
Type Description
IEnumerable<double>

A double collection of values as percentages.

Exceptions
Type Condition
ArgumentNullException

Thrown collection is null.

InvalidOperationException

Thrown if the maximum value in the collection is equal to zero.

| Edit this page View Source

ToPercentDouble(IAsyncEnumerable<int>, int, int)

Converts the values of a collection of elements int to percentages.

Declaration
public static IAsyncEnumerable<double> ToPercentDouble(this IAsyncEnumerable<int> collection, int min, int max)
Parameters
Type Name Description
IAsyncEnumerable<int> collection

Collection to process.

int min

Value that will represent 0%.

int max

Value that will represent 100%.

Returns
Type Description
IAsyncEnumerable<double>

A collection of double with its values expressed as percentages.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

InvalidOperationException

Thrown if min and max are equal.

| Edit this page View Source

ToPercentDouble(IAsyncEnumerable<int>, in int)

Converts the values of a collection of elements int to percentages.

Declaration
public static IAsyncEnumerable<double> ToPercentDouble(this IAsyncEnumerable<int> collection, in int max)
Parameters
Type Name Description
IAsyncEnumerable<int> collection

Collection to process.

int max

Value that will represent 100%.

Returns
Type Description
IAsyncEnumerable<double>

A collection of double with its values expressed as percentages.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

InvalidOperationException

Thrown if the minimum value of the collection and max are equal.

| Edit this page View Source

ToPercentDouble(IEnumerable<int>)

Converts the values of a collection of elements int to percentages.

Declaration
public static IEnumerable<double> ToPercentDouble(this IEnumerable<int> collection)
Parameters
Type Name Description
IEnumerable<int> collection

Collection to process.

Returns
Type Description
IEnumerable<double>

A collection of double with its values expressed as percentages.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

InvalidOperationException

Thrown if the minimum and maximum values of the collection are equal.

| Edit this page View Source

ToPercentDouble(IEnumerable<int>, in bool)

Converts the values of a collection of elements int to percentages.

Declaration
public static IEnumerable<double> ToPercentDouble(this IEnumerable<int> collection, in bool baseZero)
Parameters
Type Name Description
IEnumerable<int> collection

Collection to process.

bool baseZero

Optional. If true, the base of percentage is zero; otherwise, the minimum value within the collection will be used.

Returns
Type Description
IEnumerable<double>

A collection of double with its values expressed as percentages.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

InvalidOperationException

Thrown if the minimum and maximum values of the collection are equal.

| Edit this page View Source

ToPercentDouble(IEnumerable<int>, int, int)

Converts the values of a collection of elements int to percentages.

Declaration
public static IEnumerable<double> ToPercentDouble(this IEnumerable<int> collection, int min, int max)
Parameters
Type Name Description
IEnumerable<int> collection

Collection to process.

int min

Value that will represent 0%.

int max

Value that will represent 100%.

Returns
Type Description
IEnumerable<double>

A collection of double with its values expressed as percentages.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

InvalidOperationException

Thrown if min and max are equal.

| Edit this page View Source

ToPercentDouble(IEnumerable<int>, in int)

Converts the values of a collection of elements int to percentages.

Declaration
public static IEnumerable<double> ToPercentDouble(this IEnumerable<int> collection, in int max)
Parameters
Type Name Description
IEnumerable<int> collection

Collection to process.

int max

Value that will represent 100%.

Returns
Type Description
IEnumerable<double>

A collection of double with its values expressed as percentages.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

InvalidOperationException

Thrown if the minimum value of the collection and max are equal.

| Edit this page View Source

ToPercentSingle(IAsyncEnumerable<int>, int, int)

Converts the values of a collection of elements int to single-precision percentages.

Declaration
public static IAsyncEnumerable<float> ToPercentSingle(this IAsyncEnumerable<int> collection, int min, int max)
Parameters
Type Name Description
IAsyncEnumerable<int> collection

Collection to process.

int min

Value that will represent 0%.

int max

Value that will represent 100%.

Returns
Type Description
IAsyncEnumerable<float>

A collection of float with its values expressed as percentages.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

InvalidOperationException

Thrown if min and max are equal.

| Edit this page View Source

ToPercentSingle(IAsyncEnumerable<int>, in int)

Converts the values of a collection of elements int to single-precision percentages.

Declaration
public static IAsyncEnumerable<float> ToPercentSingle(this IAsyncEnumerable<int> collection, in int max)
Parameters
Type Name Description
IAsyncEnumerable<int> collection

Collection to process.

int max

Value that will represent 100%.

Returns
Type Description
IAsyncEnumerable<float>

A collection of float with its values expressed as percentages.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

InvalidOperationException

Thrown if the minimum value of the collection and max are equal.

| Edit this page View Source

ToPercentSingle(IEnumerable<int>)

Converts the values of a collection of elements int to single-precision percentages.

Declaration
public static IEnumerable<float> ToPercentSingle(this IEnumerable<int> collection)
Parameters
Type Name Description
IEnumerable<int> collection

Collection to process.

Returns
Type Description
IEnumerable<float>

A collection of float with its values expressed as percentages.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

InvalidOperationException

Thrown if the minimum and maximum values of the collection are equal.

| Edit this page View Source

ToPercentSingle(IEnumerable<int>, in bool)

Converts the values of a collection of elements int to single-precision percentages.

Declaration
public static IEnumerable<float> ToPercentSingle(this IEnumerable<int> collection, in bool baseZero)
Parameters
Type Name Description
IEnumerable<int> collection

Collection to process.

bool baseZero

Optional. If true, the base of percentage is zero; otherwise, the minimum value within the collection will be used.

Returns
Type Description
IEnumerable<float>

A collection of float with its values expressed as percentages.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

InvalidOperationException

Thrown if the minimum and maximum values of the collection are equal.

| Edit this page View Source

ToPercentSingle(IEnumerable<int>, int, int)

Converts the values of a collection of elements int to single-precision percentages.

Declaration
public static IEnumerable<float> ToPercentSingle(this IEnumerable<int> collection, int min, int max)
Parameters
Type Name Description
IEnumerable<int> collection

Collection to process.

int min

Value that will represent 0%.

int max

Value that will represent 100%.

Returns
Type Description
IEnumerable<float>

A collection of float with its values expressed as percentages.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

InvalidOperationException

Thrown if min and max are equal.

| Edit this page View Source

ToPercentSingle(IEnumerable<int>, in int)

Converts the values of a collection of elements int to single-precision percentages.

Declaration
public static IEnumerable<float> ToPercentSingle(this IEnumerable<int> collection, in int max)
Parameters
Type Name Description
IEnumerable<int> collection

Collection to process.

int max

Value that will represent 100%.

Returns
Type Description
IEnumerable<float>

A collection of float with its values expressed as percentages.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

InvalidOperationException

Thrown if the minimum value of the collection and max are equal.

| Edit this page View Source

ToTypes(IEnumerable)

Gets a list of the types of the specified objects.

Declaration
public static IEnumerable<Type> ToTypes(this IEnumerable objects)
Parameters
Type Name Description
IEnumerable objects

Objects from which to generate the collection of types.

Returns
Type Description
IEnumerable<Type>

A list composed of the types of the provided objects.

| Edit this page View Source

WhichAreNull(IEnumerable<object?>)

Determines if any of the objects are null.

Declaration
public static IEnumerable<int> WhichAreNull(this IEnumerable<object?> collection)
Parameters
Type Name Description
IEnumerable<object> collection

Collection of objects to check.

Returns
Type Description
IEnumerable<int>

An enumerator with the indices of the objects that are null.

| Edit this page View Source

WithIndex<T>(IEnumerable<T>)

Enumerates the elements of the collection, including the index of each returned element.

Declaration
public static IEnumerable<(int index, T element)> WithIndex<T>(this IEnumerable<T> collection)
Parameters
Type Name Description
IEnumerable<T> collection

Collection for which to enumerate the elements along with their index.

Returns
Type Description
IEnumerable<(int index, T element)>

An enumeration of each element along with its index.

Type Parameters
Name Description
T

Type of elements in the collection.

| Edit this page View Source

Xor(IEnumerable<bool>)

Applies the XOR operator to a collection of bool values.

Declaration
public static bool Xor(this IEnumerable<bool> collection)
Parameters
Type Name Description
IEnumerable<bool> collection

Collection to apply the operation from.

Returns
Type Description
bool

The result of applying the XOR operator to all bits in the collection.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

| Edit this page View Source

Xor(IEnumerable<byte>)

Applies the XOR operator to a collection of byte values.

Declaration
public static byte Xor(this IEnumerable<byte> collection)
Parameters
Type Name Description
IEnumerable<byte> collection

Collection to apply the operation from.

Returns
Type Description
byte

The result of applying the XOR operator to all bits in the collection.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

| Edit this page View Source

Xor(IEnumerable<char>)

Applies the XOR operator to a collection of char values.

Declaration
public static char Xor(this IEnumerable<char> collection)
Parameters
Type Name Description
IEnumerable<char> collection

Collection to apply the operation from.

Returns
Type Description
char

The result of applying the XOR operator to all bits in the collection.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

| Edit this page View Source

Xor(IEnumerable<short>)

Applies the XOR operator to a collection of short values.

Declaration
public static short Xor(this IEnumerable<short> collection)
Parameters
Type Name Description
IEnumerable<short> collection

Collection to apply the operation from.

Returns
Type Description
short

The result of applying the XOR operator to all bits in the collection.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

| Edit this page View Source

Xor(IEnumerable<int>)

Applies the XOR operator to a collection of int values.

Declaration
public static int Xor(this IEnumerable<int> collection)
Parameters
Type Name Description
IEnumerable<int> collection

Collection to apply the operation from.

Returns
Type Description
int

The result of applying the XOR operator to all bits in the collection.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

| Edit this page View Source

Xor(IEnumerable<long>)

Applies the XOR operator to a collection of long values.

Declaration
public static long Xor(this IEnumerable<long> collection)
Parameters
Type Name Description
IEnumerable<long> collection

Collection to apply the operation from.

Returns
Type Description
long

The result of applying the XOR operator to all bits in the collection.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

| Edit this page View Source

Xor(IEnumerable<sbyte>)

Applies the XOR operator to a collection of sbyte values.

Declaration
[CLSCompliant(false)]
public static sbyte Xor(this IEnumerable<sbyte> collection)
Parameters
Type Name Description
IEnumerable<sbyte> collection

Collection to apply the operation from.

Returns
Type Description
sbyte

The result of applying the XOR operator to all bits in the collection.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

| Edit this page View Source

Xor(IEnumerable<ushort>)

Applies the XOR operator to a collection of ushort values.

Declaration
[CLSCompliant(false)]
public static ushort Xor(this IEnumerable<ushort> collection)
Parameters
Type Name Description
IEnumerable<ushort> collection

Collection to apply the operation from.

Returns
Type Description
ushort

The result of applying the XOR operator to all bits in the collection.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

| Edit this page View Source

Xor(IEnumerable<uint>)

Applies the XOR operator to a collection of uint values.

Declaration
[CLSCompliant(false)]
public static uint Xor(this IEnumerable<uint> collection)
Parameters
Type Name Description
IEnumerable<uint> collection

Collection to apply the operation from.

Returns
Type Description
uint

The result of applying the XOR operator to all bits in the collection.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

| Edit this page View Source

Xor(IEnumerable<ulong>)

Applies the XOR operator to a collection of ulong values.

Declaration
[CLSCompliant(false)]
public static ulong Xor(this IEnumerable<ulong> collection)
Parameters
Type Name Description
IEnumerable<ulong> collection

Collection to apply the operation from.

Returns
Type Description
ulong

The result of applying the XOR operator to all bits in the collection.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX