如何使用c#对日历中显示的月份进行排序 [英] how to sort month as displayed in calender using c#

查看:47
本文介绍了如何使用c#对日历中显示的月份进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用C#.net对日历中显示的月份进行排序
例如,一月,二月,三月,四月.........十二月

谁能帮忙

I would like to sort month as displayed in calender using C#.net
like, January,February,March,April.........December

can anyone help

推荐答案

尝试以下示例

Try this example

static void Main()
{
var list = new List<datetime>();
list.Add(new DateTime(2010, 5, 5));
list.Add(new DateTime(2010, 10, 20));
list.Add(new DateTime(2010, 1, 4));
list.Add(new DateTime(2010, 6, 19));

Display(SortMonthAscending(list), "SortMonthAscending");
}

static List<DateTime> SortMonthAscending(List<DateTime> list)
{
    list.Sort((a, b) => a.Month.CompareTo(b.Month));
    return list;
}

static void Display(List<datetime> list, string message)
{
Console.WriteLine(message);
foreach (var datetime in list)
{
    Console.WriteLine(datetime);
}
Console.WriteLine();
}</datetime></datetime>



这应该可以帮助您对日期进行排序.


干杯



This should help you sorting your dates.


Cheers


这篇关于如何使用c#对日历中显示的月份进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆