You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
static readonly SlimSerializer serializer = new SlimSerializer();
static byte[] Serialize(object obj)
{
using (var ms = new MemoryStream())
{
serializer.Serialize(ms, obj);
return ms.ToArray();
}
}
static object Deserialize(byte[] data)
{
using (var ms = new MemoryStream(data))
{
return serializer.Deserialize(ms);
}
}
static void Main(string[] args)
{
var dateTimeOffsetNow = DateTimeOffset.Now;
var packedDateTimeOffset = new {Now = dateTimeOffsetNow};
var serializedDateTimeOffset = Serialize(dateTimeOffsetNow);
var serializedPackedDateTimeOffset = Serialize(packedDateTimeOffset);
var deserializedDateTimeOffsetNow = Deserialize(serializedDateTimeOffset);
var deserializedPackedDateTimeOffset = (dynamic) Deserialize(serializedPackedDateTimeOffset);
}
// dateTimeOffsetNow: 6/27/2019 1:02:12 PM +03:00
// deserializedDateTimeOffsetNow: 6/27/2019 1:02:12 PM +03:00
// packedDateTimeOffset.Now: 6/27/2019 1:02:12 PM +03:00
// deserializedPackedDateTimeOffset.Now: 1/1/0001 12:00:00 AM +00:00
The text was updated successfully, but these errors were encountered:
kalteherz
changed the title
Packed DateTimeOffset is equal to MinValue after deserialization
(Slim) Packed DateTimeOffset is equal to MinValue after deserialization
Jun 27, 2019
The text was updated successfully, but these errors were encountered: