2005年2月1日
01.02.2010 0:00:00 -> 01.02.2010 页: 1
因此,我的日期是:
DateTime x;
it s 01.02.2010 0:00:00 as a string
x.Date.ToString()
我在此比较了日期。
DatarowsForOneDay = dt.Select("DailyRecTime= " + x.ToString() + " ");
因此,我如何按日加几个小时,不关心几分钟和秒钟。
2005年2月1日
01.02.2010 0:00:00 -> 01.02.2010 页: 1
因此,我的日期是:
DateTime x;
it s 01.02.2010 0:00:00 as a string
x.Date.ToString()
我在此比较了日期。
DatarowsForOneDay = dt.Select("DailyRecTime= " + x.ToString() + " ");
因此,我如何按日加几个小时,不关心几分钟和秒钟。
你可以撰写自己的<条码>IEqualityComparer<Datetime>,仅比较你所关心的那部分时间。 LINQ 团体 载重:<代码> IEqualityComparer 。 我最近也有同样的问题,只是这样做了。
但是,在转换成星之前,你必须打上<条码>。 如果你可以的话,你可能会想建立<条码>。 缩略语
我现在没有与我一道制定原来的法典。 我从记忆中重新归类,没有测试。
public class DateAndHourComparer : IEqualityComparer
{
public bool Equals(DateTime x, DateTime y)
{
var xAsDateAndHours = AsDateHoursAndMinutes(x);
var yAsDateAndHours = AsDateHoursAndMinutes(y);
return xAsDateAndHours.Equals(yAsDateAndHours);
}
private DateTime AsDateHoursAndMinutes(DateTime dateTime)
{
return new DateTime(dateTime.Year, dateTime.Month,
dateTime.Day, dateTime.Hour,
dateTime.Minute, 0);
}
public int GetHashCode(DateTime obj)
{
return AsDateHoursAndMinutes(obj).GetHashCode();
}
}
我从来就没有这样作,但可以使用以上<代码>Datetime的代号,看像......。
public class DateAndHourStringComparer : IEqualityComparer
{
private readonly DateAndHourComparer dateComparer = new DateAndHourComparer();
public bool Equals(string x, string y)
{
var xDate = DateTime.Parse(x);
var yDate = DateTime.Parse(y);
return dateComparer.Equals(xDate, yDate);
}
public int GetHashCode(string obj)
{
var date = DateTime.Parse(obj);
return dateComparer.GetHashCode(date);
}
}
我没有对此进行测试,我没有增加检查或格式检查。 该守则旨在表明一般的想法。
You can pass a parameter with DateTime.ToString(string pattern). More information @ http://www.geekzilla.co.uk/View00FF7904-B510-468C-A2C8-F859AA20581F.htm.
What is the use of default keyword in C#? Is it introduced in C# 3.0 ?
I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...
I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...
I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...
I have two EF entities. One has a property called HouseNumber. The other has two properties, one called StartHouseNumber and one called EndHouseNumber. I want to create a many to many association ...
How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...
Since I cannot order my dictionary, what is the best way of going about taking key value pairs and also maintaing an index?
Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...