DateTime转long: public static long GetDateLong(object time) { DateTime epoc = TimeZone.CurrentTimeZone.ToLocalTime(, , )); TimeSpan delta = new TimeSpan(); if (time is DateTime) delta = ((DateTime)time).Subtract(epoc); else if (time is string) delta =…
C#的System.DateTime类提供了对日期时间的封装,用它进行时间的转换和处理很方便,但是我没有在其中找到任何可以用来修改系统时间的成员.用过VC.VB等的朋友可能知道,我们可以调用Win32 API SetLocalTime来改变系统时间,看来C#中也只能如此了.SetLocalTime需要一个SYSTEMTIME结构指针作为参数,这倒不难,我们可以"比葫芦画瓢"很快在C#中定义这个结构,但问题是,我同时还想"享受".NET Framework的Syste…
XML 和 List 互转类 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Xml; namespace XmlHelper { /// <summary> /// 实体转Xml,Xml转实体类 /// </summary> /// <typeparam name="T"&g…