功能
查询起止日期范围内连续的月份列表。
/* Period */ cbxPeriod.DataSource = Enumerable.Range(0, 24).Select(t => DateTime.Today.AddMonths(-t)).Select(t => new KeyValuePair<string, string>(t.ToString("yyyy-MM"), t.ToString("yyyy-MM"))).ToList(); cbxPeriod.ValueMember = "Key"; cbxPeriod.DisplayMember = "Value";
参考资料
https://stackoverflow.com/a/25081986