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

后端 未结 16 1020
栀梦
栀梦 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:05

    They're defined as an array in the Globalization namespaces.

    using System.Globalization;
    
    for (int i = 0; i < 12; i++) {
       Console.WriteLine(CultureInfo.CurrentUICulture.DateTimeFormat.MonthNames[i]);
    }
    

提交回复
热议问题