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());     } 

and

    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?

Replay

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

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

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