By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,497 Members | 1,287 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,497 IT Pros & Developers. It's quick & easy.

Convert DateTime to Byte Array?

P: n/a
I need to covert DateTime Variables into a byte array but all of the
conversion methods do not appear to handle the DateTime type. Is
there a generic way to convert any property or object into a byte
array?

Thanks

Nov 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
David <ma******@sbcglobal.net> wrote:
I need to covert DateTime Variables into a byte array but all of the
conversion methods do not appear to handle the DateTime type. Is
there a generic way to convert any property or object into a byte
array?


Well, there's serialization - but for a DateTime, the easiest thing
would be to use the Ticks property to convert it to a long, and then
convert that into a byte array.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #2

P: n/a
David,

Because that the datetime is a value, that exist as ticks in the format
long, has it not such much sense to place that in a byteArray. Probably you
want a byte array of a ToString converted format. However that is than
depending from the way as you want it in that byte array.

I hope this helps

Cor
Nov 17 '05 #3

P: n/a
I never considered ticks! I tried a string, but when you convert
back, you loose the time portion!

Thanks

On Wed, 23 Mar 2005 06:52:44 -0000, Jon Skeet [C# MVP]
<sk***@pobox.com> wrote:
David <ma******@sbcglobal.net> wrote:
I need to covert DateTime Variables into a byte array but all of the
conversion methods do not appear to handle the DateTime type. Is
there a generic way to convert any property or object into a byte
array?


Well, there's serialization - but for a DateTime, the easiest thing
would be to use the Ticks property to convert it to a long, and then
convert that into a byte array.


Nov 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.