Initialize

Creates a collection by calling the given initializer on each index.

WARNING

This method isn't available as an extension method.

Parameters

Returns

int length

Func<int, T> initializer

IEnumerable<T>

Usage

Creating an integer collection

IEnumerable<int> result = 
    CollectionModule.Initialize(5, index => index * 2);

//result = { 0, 2, 4, 6, 8 }

Last updated