How to list all month names, e.g. for a combo?

后端 未结 16 1023
栀梦
栀梦 2020-12-23 14:38

At the moment I\'m creating a DateTime for each month and formatting it to only include the month.
Is there another or any better way to do this?

16条回答
  •  盖世英雄少女心
    2020-12-23 14:50

    You can easily do something like below with linq so that you only have 12 items in your drop down.

    var Months = new SelectList((DateTimeFormatInfo.CurrentInfo.MonthNames).Take(12));
    

提交回复
热议问题