DateTime compare

DateTime t1 = new DateTime(100);
DateTime t2 = new DateTime(20);

if (DateTime.Compare(t1, t2) >  0) Console.WriteLine("t1 > t2"); 
if (DateTime.Compare(t1, t2) == 0) Console.WriteLine("t1 == t2"); 
if (DateTime.Compare(t1, t2) <  0) Console.WriteLine("t1 < t2");
 
 DateTime.Compare(datetime1,datetime2)的输入为-1,0,1

值类型                   条件

小于零              t1 小于 t2
零                     t1 等于 t2
大于零             t1 大于 t2

http://msdn.microsoft.com/zh-cn/library/system.datetime.compare(v=VS.80).aspx
posted @ 2013-09-29 12:04  沧海一滴  阅读(510)  评论(0编辑  收藏  举报