Last active
August 29, 2015 14:19
-
-
Save jongha/7d549fbcf385dedcc582 to your computer and use it in GitHub Desktop.
GetListItems using Func Generic in C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Func<List<int>, ListItem[]> GetListItems = (items) => | |
{ | |
List<ListItem> list = new List<ListItem>(); | |
foreach(int i in items) | |
{ | |
string item = i.ToString("D2"); | |
list.Add(new ListItem() | |
{ | |
Text = item, | |
Value = item | |
}); | |
} | |
return list.ToArray(); | |
}; | |
dropListYear.Items.AddRange(GetListItems(Enumerable.Range(DateTime.Now.Year - 99, 100).Reverse().ToList())); | |
dropListMonth.Items.AddRange(GetListItems(Enumerable.Range(1, 12).ToList())); | |
dropListDay.Items.AddRange(GetListItems(Enumerable.Range(1, 31).ToList())); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment