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

后端 未结 16 1026
栀梦
栀梦 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 15:14

    Try enumerating the month names:

    for( int i = 1; i <= 12; i++ ){
      combo.Items.Add(CultureInfo.CurrentCulture.DateTimeFormat.MonthNames[i]);
    }
    

    It's in the System.Globalization namespace.

    Hope that helps!

提交回复
热议问题