不同日期的清单 [英] List of distinct dates
本文介绍了不同日期的清单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下代码:
List<DateTime> dates = new List<DateTime>();
//filling the list somehow
dates = dates.Distinct().ToList();
代码基本上可以正常工作,但是我得到了唯一的DateTime列表。我想获取唯一日期列表,因为这里根本不需要时间。
The code is basically working but I get the list of unique DateTime. And I want to get the list of unique dates since I don't need times at all here. Is there a nice solution?
我的问题不同于
因为我实际上没有查询数据库。我只想过滤列表。
since I am not quering the database actually. I just want to filter the list.
推荐答案
如何使用转换选择?
将序列中的每个元素投影到新形式。
Projects each element of a sequence into a new form.
类似
dates = dates.Select(x => x.Date).Distinct().ToList();
这篇关于不同日期的清单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文