编程岁月

软件开发技术心得&笔记

徐钧ID:jamex
198945次访问,排名324好友0人,关注者18
jamex的文章
原创 51 篇
翻译 0 篇
转载 214 篇
评论 12 篇
jamex的公告
欢迎光临!
最近评论
smoily:用Winform,Win 2000的服务器又该怎样配置呢?
smoily:如果是Winform怎样上传文件呢?真的是一头雾水呢
xkpkhu:wow power leveling
kuangrenkuaile:好!真好!经典!!!!
ll_abc20:这方法不行啊
文章分类
收藏
相册
我的相册
分站链接
我的70年代之无痕记忆收容院
户外采风
机灵狗的BLOG
个人技术站点
【孟子E章】
E路网
First we try, then we trust (设计模式)
乱闪Blog
孙展波 Realize .NET Potential (中文版)
宝玉的blog
屋顶上的木帷幕(RSS)
开心就好
心动空间
思归呓语
无忧视窗
梅花雪中文网
翱翔.Net Blog
蝈蝈俊.net
邹建的专栏
技术论坛
ITPUB论坛
中国DotNet俱乐部
友缘相聚-数据结构专栏
百易论坛
技术资料参考
.NET技术问题精华帖汇总
1000本電腦IT網路電子書專題下載
CDSNWeb开发ASP问题好贴链接集合、学习资源!
协议大全
正则表达式工作室(Regular Expression Laboratory)
设计模式(Patterns in Java)
商业技术站点
【中国WEB开发者网络】
MSDN WebCast网络广播全部下载列表
PcOnline开发特区
VC知识库
www.codeproject.com
中国it动力(china it power)
天极网技术开发者网络
子虚IT网
微软“8分钟”系列课程
微软MSDN Webcasts
放心去飞(项目体系方面)
源码示例
中国源码中心
代码爱好者
源码网
源码联盟
破釜沉舟
程序太平洋
存档
软件项目交易
订阅我的博客
XML聚合  FeedSky
订阅到鲜果
订阅到Google
订阅到抓虾
订阅到BlogLines
订阅到Yahoo
订阅到GouGou
订阅到飞鸽
订阅到Rojo
订阅到newsgator
订阅到netvibes

转载 C#里面比较时间大小三种方法收藏

新一篇: Internet Explorer Cannot Download Office Documents from an IIS Server When Content Expiration Is Set to Expire Immediately | 旧一篇: Can I get rid of the "This page contains both secure and nonsecure items" warning?

1。比较时间大小的实验  
      string   st1="12:13";  
        string   st2="14:14";  
        DateTime   dt1=Convert.ToDateTime(st1);  
        DateTime   dt2=Convert.ToDateTime(st2);  
        DateTime   dt3=DateTime.Now;  
        if(DateTime.Compare(dt1,dt2)>0)  
          msg.Text=st1+">"+st2;  
        else  
          msg.Text=st1+"<"+st2;  
        msg.Text+="\r\n"+dt1.ToString();  
        if(DateTime.Compare(dt1,dt3)>0)  
          msg.Text+="\r\n"+st1+">"+dt3.ToString();  
        else  
          msg.Text+="\r\n"+st1+"<"+dt3.ToString();  
   
  2。计算两个时间差值的函数,返回时间差的绝对值:  
                  private   string   DateDiff(DateTime   DateTime1,DateTime   DateTime2)  
                  {  
                          string   dateDiff=null;  
                          try  
                          {  
                                  TimeSpan   ts1=new     TimeSpan(DateTime1.Ticks);  
                                  TimeSpan   ts2=new     TimeSpan(DateTime2.Ticks);  
                                  TimeSpan   ts=ts1.Subtract(ts2).Duration();  
                                  dateDiff=ts.Days.ToString()+"天"  
                                                  +ts.Hours.ToString()+"小时"  
                                                  +ts.Minutes.ToString()+"分钟"  
                                                  +ts.Seconds.ToString()+"秒";  
                          }  
                          catch  
                          {  
   
                          }  
                          return   dateDiff;  
                  }  
   
  3。实现计算DateTime1-36天=DateTime2的功能  
   
        TimeSpan   ts=new   TimeSpan(40,0,0,0);  
        DateTime   dt2=DateTime.Now.Subtract(ts);  
        msg.Text=DateTime.Now.ToString()+"-"+ts.Days.ToString()+"天\r\n";  
        msg.Text+=dt2.ToString();  

发表于 @ 2008年04月23日 15:06:30|评论(loading...)|编辑

新一篇: Internet Explorer Cannot Download Office Documents from an IIS Server When Content Expiration Is Set to Expire Immediately | 旧一篇: Can I get rid of the "This page contains both secure and nonsecure items" warning?

评论

#kuangrenkuaile 发表于2008-05-17 08:33:36  IP: 60.207.133.*
好!真好!经典!!!!
发表评论  


当前用户设置只有注册用户才能发表评论。如果你没有登录,请点击登录
Csdn Blog version 3.1a
Copyright © jamex