public void Workingwithcollections() { for (int i = hour; i <= 17; i++) { Hour.Add(new ButtonWithColors() { Number = i, Colorr = "White" }); } for (int i = 0; i <= 50; i = i + 10) { Minute.Add(new ButtonWithColors() { Number = i, Colorr = "White" }); } }
private void PopulateDateCollection() { //populate Days for (int i = 1; i <= DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month); i++) { if (i < 10) { Day.Add("0" + i); } else { Day.Add(i.ToString()); } } //populate year for (int i = 1990; i < 2050; i++) { Year.Add(i.ToString()); } //populate months for (int i = 1; i < 13; i++) { if (!Months.ContainsKey(CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(i).Substring(0, 3))) { Months.Add(CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(i).Substring(0, 3), CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(i)); } Month.Add(CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(i).Substring(0, 3)); } Date.Add(Year); Date.Add(Month); Date.Add(Day); for (int i = 1; i <= 24; i++) { if (i < 10) { Hour.Add("0" + i.ToString()); } else { Hour.Add(i.ToString()); } } for (int j = 0; j < 60; j++) { if (j < 10) { Minute.Add("0" + j); } else { Minute.Add(j.ToString()); } } Date.Add(Hour); Date.Add(Minute); }