How to serialize a DateTimeOffset into a binary stream

I'm wondering what would be the best way to serialize a DateTimeOffset into a binary stream (using a BinaryWriter) and deserialize it again (using a BinaryReader).

To serialize a DateTime, I have:

    public void WriteValue(DateTime value)     {         _writer.Write(value.ToBinary());     } 


    public DateTime ReadDateTime()     {         return DateTime.FromBinary(_reader.ReadInt64());     } 

What is the best approach to serialize/deserialize a DateTimeOffset in terms of performance and storage size?


Category: c# Time: 2016-07-31 Views: 16
Tags: .net bcl

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development


Front-end development


development tools

Open Platform

Javascript development

.NET development

cloud computing


Copyright (C), All Rights Reserved.

processed in 0.166 (s). 12 q(s)