Skip to content

Instantly share code, notes, and snippets.

@MisterJames
Created March 13, 2013 01:28
Show Gist options
  • Select an option

  • Save MisterJames/5148675 to your computer and use it in GitHub Desktop.

Select an option

Save MisterJames/5148675 to your computer and use it in GitHub Desktop.
An easy way to build out hour and minute select list items.
class Program
{
static void Main(string[] args)
{
IEnumerable<int> hours =
Enumerable.Range(0, 24);
IEnumerable<int> minutes =
Enumerable.Range(0, 2).Select(x => x * 30);
List<string> timeOptions = new List<string>();
foreach (var hour in hours)
{
foreach (var minute in minutes)
{
timeOptions.Add(string.Format("{0}:{1:00}", hour, minute));
}
}
timeOptions.ForEach(s => Console.WriteLine(s));
Console.ReadLine();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment