score:10

Accepted answer

this can be achieved using enumerable.range

list<int> integerlist = enumerable.range(minvalue, maxvalue - minvalue).tolist();

score:1

you could use a collection initializer.

http://msdn.microsoft.com/en-us/library/bb384062.aspx

private list integerlist = new list{minvalue, maxvalue};

score:1

you could use enumerable.range

list<int> integerlist = enumerable.range(minvalue, maxvalue - minvalue).tolist();

score:1

try ienumerable.range(minvalue, maxvalue-minvalue).tolist(): msdn

score:2

assuming maxvalue is always > minvalue,

var integerlist = enumerable.range(minvalue, maxvalue-minvalue).tolist();

score:3

just use the enumerable.range(int start, int count) method:

generates a sequence of integral numbers within a specified range.

a simple example, using your minvalue and maxvalue variables:

list<int> integerlist = enumerable.range(minvalue, maxvalue - minvalue).tolist();

note that if maxvalue is less than minvalue, the count parameter will be less than zero and an argumentoutofrangeexception will be thrown.


Related Query

More Query from same tag