Best practices for DateTime serialization in .NET 3.5

前端 未结 6 1775
执念已碎
执念已碎 2020-12-01 10:45

Some 4 years back, I followed this MSDN article for DateTime usage best practices for building a .Net client on .Net 1.1 and ASMX web services (with SQL 2000 server as the b

6条回答
  •  醉酒成梦
    2020-12-01 11:37

    For cases where the datetime object should simply stay the same use JsonConvert:

    DateTime now = DateTime.Now;
    string json = JsonConvert.SerializeObject(now);
    DateTime nowJson = JsonConvert.DeserializeObject(json);
    

提交回复
热议问题