I need to generate a list of sequential numbers. I know Ruby you can do 1..10 or PHP you can do range(1, 10). Anything like that in .Net already, or do I have to write it? Thanks.
A:
Would this work for you?
public List<int> Range(int start, int finish)
{
List<int> retList = new List<int>();
for(int i = start; i <= finish; i++)
{
retList.Add(i);
}
return retList;
}
scottm
2009-01-14 16:33:32
I actually wrote a method exactly like this before I saw you could use Enumerable.Range. Thanks.
Kevin
2009-01-14 16:43:14
Yeah, that's new to me also. I really need to get a 3.0 book, but I think I'm just going to wait until 4.0
scottm
2009-01-14 17:05:29