Contains static generic ToArray method for producing an Array from a collection.
Static Public Member Functions |
|
static T[] | ToArray< T > (ICollection collection) |
Static generic method produces a new array
of the generic parameter type from the given ICollection. |
|
static T[] | Slice< T > (T[] source, int fromIndex) |
Generates a new array from a subset of the
source array. |
|
static T[] | Slice< T > (T[] source, int fromIndex, int length) |
Generates a new array from a subset of the
source array. |
static T [] CSharpUtilities::ArrayProducer::ToArray< T > | ( | ICollection | collection | ) | [inline, static] |
Static generic method produces a new array of the generic parameter type from the given ICollection.
T | Target array item type |
collection | Source collection. All items in this collection will be placed in the returned array. |
static T [] CSharpUtilities::ArrayProducer::Slice< T > | ( | T[] | source, |
int | fromIndex | ||
) | [inline, static] |
Generates a new array from a subset of the source array.
This version copies from the given index until the end of the array.
Example:
int[] source = {0,1,2,3,4,5}; int[] result = ArrayProducer.Slice(source, 3); // result is now: {3,4,5} result = ArrayProducer.Slice(source, 6); // result is now: {}
Slice can operate on multidimensional arrays, but it only considers the first array.
T | The array item type. |
source | Source array, the selected elements from here will be copied into the new array. |
fromIndex | The index at which to start selecting elements. |
source.Length - fromIndex
,
containing the elements from source[fromIndex]
until
source[source.Length - 1]
.static T [] CSharpUtilities::ArrayProducer::Slice< T > | ( | T[] | source, |
int | fromIndex, | ||
int | length | ||
) | [inline, static] |
Generates a new array from a subset of the source array.
This version copies the given length of elements starting from the given index.
Example:
int[] source = {0,1,2,3,4,5}; int[] result = ArrayProducer.Slice(source, 3, 2); // result is now: {3,4} result = ArrayProducer.Slice(source, 5, 2); // result is now: {5, 0} 0 is the default value for int result = ArrayProducer.Slice(source, 0, 0); // result is now: {}
Slice can operate on multidimensional arrays, but it only considers the first array.
T | The array item type. |
source | Source array, the selected elements from here will be copied into the new array. |
fromIndex | The index at which to start selecting elements. |
length | The desired length of the resulting array. Up to this many elements will be copied from the source array. Fewer than length will be copied if length exceeds the size of the array past fromIndex. Any value less than 0 will be clamped to 0. |
length
, containing the
elements from source[fromIndex]
until
source[Math.Min(source.Length - 1, fromIndex + length -
1)]
and padded with null or default values at the end as
necessary.