标签:oca creat new set line oid oaf string alt
class Program
{
static void Main(string[] args)
{
UserInfo userInfo = new UserInfo();
userInfo.CreateTime = DateTime.Now;
string userString = SlJson.ToJson(userInfo);//序列化
UserInfo userInfoAfter = SlJson.FromJson<UserInfo>(userString);//反序列化
Console.WriteLine("时间戳:" + userString);
Console.WriteLine("转换后:" + userInfoAfter.CreateTime);
Console.WriteLine("本地" + userInfoAfter.CreateTime.ToLocalTime());
Console.ReadKey();
}
}
public class UserInfo
{
public DateTime CreateTime { get; set; }
}
C#对象先序列化然后反序列化时间丢失八小时的问题 ToLocalTime
标签:oca creat new set line oid oaf string alt
原文地址:http://www.cnblogs.com/lushixiong/p/6897804.html