zoukankan      html  css  js  c++  java
  • DateTime.Compare(t1,t2)比较两个日期大小

    DateTime.Compare(t1,t2)比较两个日期大小,排前面的小,排在后面的大,比如:2011-2-1就小于2012-3-2
    返回值小于零:  t1 小于 t2。 
    返回值等于零 : t1 等于 t2。 
    返回值大于零:  t1 大于 t2。 

    如:

    [c-sharp] view plain copy
     
    1. using System;  
    2. using System.Collections.Generic;  
    3. using System.Linq;  
    4. using System.Text;  
    5.   
    6. namespace ConsoleApplication1  
    7. {  
    8.     class Program  
    9.     {  
    10.         static void Main(string[] args)  
    11.         {  
    12.   
    13.             DateTime t1 = DateTime.Parse("2011-2-2");  
    14.             DateTime t2 = DateTime.Parse("2011-3-1");  
    15.   
    16.             if (DateTime.Compare(t1, t2) > 0)   
    17.                 Console.WriteLine("t1 > t2");  
    18.             if (DateTime.Compare(t1, t2) == 0)   
    19.                 Console.WriteLine("t1 == t2");  
    20.             if (DateTime.Compare(t1, t2) < 0)   
    21.                 Console.WriteLine("t1 < t2");  
    22.         }  
    23.     }  
    24. }  

     

    运行结果:

    t1 < t2
    请按任意键继续. . .

    文章出处:https://blog.csdn.net/aspnet2002web/article/details/6171415

  • 相关阅读:
    STL目录
    Hola!
    SWPUCTF 2019总结以及部分WP
    SQL手工注入基础篇
    JDK11,JDK12没有JRE的解决方法
    FJUT2019暑假周赛三部分题解
    FJUT2019暑假周赛一题解
    随笔1
    关于针对本校教务系统漏洞的一次信息检索
    KMP算法讲解
  • 原文地址:https://www.cnblogs.com/net-sky/p/9236531.html
Copyright © 2011-2022 走看看