Skip to content

Instantly share code, notes, and snippets.

@MisterJames
Created March 13, 2013 01:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save MisterJames/5148715 to your computer and use it in GitHub Desktop.
Save MisterJames/5148715 to your computer and use it in GitHub Desktop.
A condensed version of building a list of valid times for a user to select from.
List<string> times = new List<string>();
Enumerable.Range(0, 24).ToList()
.ForEach(hour => Enumerable.Range(0, 2).ToList()
.Select(x => string.Format("{0}:{1:00}", hour, x * 30))
.ToList()
.ForEach(timeslot=>times.Add(timeslot)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment