Index - Kalkwst/Risotto GitHub Wiki
Returns a sequence of KeyValuePair<TKey, TValue> where the key is the zero-based index of the value in the source sequence.
In this page
| Overload | Description |
|---|---|
| Index() | Returns a sequence of KeyValuePair<TKey, TValue> where the key is the zero-based index of the value in the source sequence. |
| Index(int index) | Returns a sequence of KeyValuePair<TKey, TValue> where the key is the zero-based index of the value in the source sequence. An additional parameter specifies the starting index. |
Returns a sequence of KeyValuePair<TKey, TValue> where the key is the zero-based index of the value in the source sequence.
public static IEnumerable<KeyValuePair<int, TSource>> Index<TSource>(this IEnumerable<TSource> source);TSource
The type of the elements of the sequences.
source IEnumerable <TSource>
The source sequence.
IEnumerable <KeyValuePair<int, TSource>>
A sequence of KeyValuePair<int, TSource> with the key being the index and value being the element at the specific index of the sequence.
ArgumentNullException
source is null
The following code example demonstrates how to use Index() to index a sequence
int[] sourceNumbers = new int[]{1, 2, 3, 4, 5};
IEnumerable<KeyValuePair<int, int>> result = sourceNumbers.Index();
/**
=>[
{0, 1},
{1, 2},
{2, 3},
{3, 4},
{4, 5}
]**/`
eturns a sequence of KeyValuePair<TKey, TValue> where the key is the zero-based index of the value in the source sequence. An additional parameter specifies the starting index.
public static IEnumerable<KeyValuePair<int, TSource>> Index<TSource>(this IEnumerable<TSource> source, int startIndex);TSource
The type of the elements of the sequences.
source IEnumerable <TSource>
The source sequence.
startIndex Int32
The starting index.
IEnumerable <KeyValuePair<int, TSource>>
A sequence of KeyValuePair<int, TSource> with the key being the index and value being the element at the specific index of the sequence.
ArgumentNullException
source is null
The following code example demonstrates how to use Index(int index) to index a sequence from a starting index.
IEnumerable<KeyValuePair<int, int>> result = new[] { 1, 2, 3 }.Index(10);
/**
=>[
{10, 1},
{11, 2},
{12, 3}
]**/