Monday, June 15, 2015

Populate an array

I needed a quick array of the integers to represent calendar years for use with a phone app.
The solution was quite simple using the range.enumerate method

DateTime start = DateTime.Now.AddYears(-40);
DateTime end = DateTime.Now.AddYears(40);
return Enumerable.Range(start.Year, end.Year - start.Year).ToArray();

No comments:

Post a Comment