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。

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
    
                DateTime t1 = DateTime.Parse("2011-2-2");
                DateTime t2 = DateTime.Parse("2011-3-1");
    
                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");
            }
        }
    }

    运行结果:

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

  • 相关阅读:
    文本数据清洗总结
    PyTorch
    PyTorch
    NLP
    TF
    TF
    TF
    cairosvg
    word2vec 实现 影评情感分析
    Gensim
  • 原文地址:https://www.cnblogs.com/eaysun/p/4253151.html
Copyright © 2011-2022 走看看