让我们说我们有
DateTime t1 = DateTime.Parse("2012/12/12 15:00:00.000");
和
DateTime t2 = DateTime.Parse("2012/12/12 15:03:00.000");
如何在C#中比较和说哪个时间晚于?
How to compare it in C# and say which time is "is later than"?
谢谢!
您可以使用的的TimeOfDay 财产和使用比较的反对。
You can use the TimeOfDay property and use the Compare against it.
TimeSpan.Compare(t1.TimeOfDay, t2.TimeOfDay)
每文档:
-1 if t1 is shorter than t2.
0 if t1 is equal to t2.
1 if t1 is longer than t2.