Generating numbers list in C#

This would probably be a bit faster – and it’s certainly simpler:

int[] values = Enumerable.Range(start, end - start).ToArray();

Do you definitely need it as an array though? If you only need to iterate over it, you could just use Enumerable.Range directly, to get an IEnumerable<int> which never needs to actually hold all the numbers in memory at the same time.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)