Geeks With Blogs

The Wrecking Bawl Destructuring query language, one keyword at a time. April 2010 Entries
creating a list of consecutive integers in c#
If there's already a way to get a List<int> of consecutive integers without a loop in C#, I don't know what it is, so I created a method for it. public static List<int> GetIntegerListFromRangeUsin... start, int end) { if (end < start) { throw new ArgumentException("Faulty parameter(s) passed: lower bound cannot be less than upper bound."); } List<int> returnList = new List<int>(end - start + 1); for(int i = start; i <= end; i++) { returnList.Add(i); } return returnList; ......

Posted On Wednesday, April 28, 2010 7:17 AM

Copyright © Alex Bransky | Powered by: