Show / Hide Table of Contents

Class Sequence

Various methods to work with classes implementing interface.

Inheritance
Object
Sequence
Namespace: DotNext
Assembly: DotNext.dll
Syntax
public static class Sequence : object

Methods

| Improve this Doc View Source

Append<T>(IEnumerable<T>, T[])

Adds items to the end of collection.

Declaration
public static IEnumerable<T> Append<T>(this IEnumerable<T> collection, params T[] items)
Parameters
Type Name Description
IEnumerable<T> collection

The collection to be concatenated with the items.

T[] items

The items to be added to the end of the collection.

Returns
Type Description
IEnumerable<T>

The concatenated collection.

Type Parameters
Name Description
T

The type of items in the collection.

| Improve this Doc View Source

ElementAt<T>(IEnumerable<T>, Int32, out T)

Obtains elements at the specified index in the sequence.

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

Source collection.

Int32 index

Index of the element to read.

T element

Obtained element.

Returns
Type Description
Boolean

true, if element is available in the collection and obtained successfully; otherwise, false.

Type Parameters
Name Description
T

Type of elements in the sequence.

Remarks

This method is optimized for types and .

| Improve this Doc View Source

FirstOrEmpty<T>(IEnumerable<T>)

Obtains first value in the sequence; or Empty if sequence is empty.

Declaration
public static Optional<T> FirstOrEmpty<T>(this IEnumerable<T> seq)
Parameters
Type Name Description
IEnumerable<T> seq

A sequence to check. Cannot be null.

Returns
Type Description
Optional<T>

First element in the sequence; or Empty if sequence is empty.

Type Parameters
Name Description
T

Type of elements in the sequence.

| Improve this Doc View Source

FirstOrNull<T>(IEnumerable<T>)

Obtains first value type in the sequence; or null if sequence is empty.

Declaration
public static T? FirstOrNull<T>(this IEnumerable<T> seq)

    where T : struct
Parameters
Type Name Description
IEnumerable<T> seq

A sequence to check. Cannot be null.

Returns
Type Description
Nullable<T>

First element in the sequence; or null if sequence is empty.

Type Parameters
Name Description
T

Type of elements in the sequence.

| Improve this Doc View Source

ForEach<T>(IEnumerable<T>, Action<T>)

Apply specified action to each collection element.

Declaration
public static void ForEach<T>(this IEnumerable<T> collection, Action<T> action)
Parameters
Type Name Description
IEnumerable<T> collection

A collection to enumerate. Cannot be null.

Action<T> action

An action to applied for each element.

Type Parameters
Name Description
T

Type of elements in the collection.

| Improve this Doc View Source

ForEach<T>(IEnumerable<T>, ValueAction<T>)

Apply specified action to each collection element.

Declaration
public static void ForEach<T>(this IEnumerable<T> collection, in ValueAction<T> action)
Parameters
Type Name Description
IEnumerable<T> collection

A collection to enumerate. Cannot be null.

ValueAction<T> action

An action to applied for each element.

Type Parameters
Name Description
T

Type of elements in the collection.

| Improve this Doc View Source

Prepend<T>(IEnumerable<T>, T[])

Adds items to the beginning of collection.

Declaration
public static IEnumerable<T> Prepend<T>(this IEnumerable<T> collection, params T[] items)
Parameters
Type Name Description
IEnumerable<T> collection

The collection to be concatenated with the items.

T[] items

The items to be added to the beginning of the collection.

Returns
Type Description
IEnumerable<T>

The concatenated collection.

Type Parameters
Name Description
T

The type of items in the collection.

| Improve this Doc View Source

SequenceHashCode(IEnumerable<Object>, Boolean)

Computes hash code for the sequence of objects.

Declaration
public static int SequenceHashCode(this IEnumerable<object> sequence, bool salted = true)
Parameters
Type Name Description
IEnumerable<Object> sequence

The sequence of elements.

Boolean salted

true to include randomized salt data into hashing; false to use data from memory only.

Returns
Type Description
Int32

The hash code computed from each element in the sequence.

| Improve this Doc View Source

Singleton<T>(T)

Constructs a sequence from the single element.

Declaration
public static IEnumerable<T> Singleton<T>(T item)
Parameters
Type Name Description
T item

An item to be placed into sequence.

Returns
Type Description
IEnumerable<T>

Sequence of single element.

Type Parameters
Name Description
T

Type of element.

| Improve this Doc View Source

Skip<T>(IEnumerator<T>, Int32)

Bypasses a specified number of elements in a sequence.

Declaration
public static bool Skip<T>(this IEnumerator<T> enumerator, int count)
Parameters
Type Name Description
IEnumerator<T> enumerator

Enumerator to modify. Cannot be null.

Int32 count

The number of elements to skip.

Returns
Type Description
Boolean

true, if current element is available; otherwise, false.

Type Parameters
Name Description
T
| Improve this Doc View Source

SkipNulls<T>(IEnumerable<T>)

Skip null values in the collection.

Declaration
public static IEnumerable<T> SkipNulls<T>(this IEnumerable<T> collection)

    where T : class
Parameters
Type Name Description
IEnumerable<T> collection

A collection to check. Cannot be null.

Returns
Type Description
IEnumerable<T>

Modified lazy collection without null values.

Type Parameters
Name Description
T

Type of elements in the collection.

| Improve this Doc View Source

ToString<T>(IEnumerable<T>, String, String)

Concatenates each element from the collection into single string.

Declaration
public static string ToString<T>(this IEnumerable<T> collection, string delimiter, string ifEmpty = "")
Parameters
Type Name Description
IEnumerable<T> collection

Collection to convert. Cannot be null.

String delimiter

Delimiter between elements in the final string.

String ifEmpty

A string to be returned if collection has no elements.

Returns
Type Description
String

Converted collection into string.

Type Parameters
Name Description
T

Type of array elements.

  • Improve this Doc
  • View Source
Back to top Generated by DocFX