BitConverter and back again?

  • Thread starter Thread starter Gabe Jahn
  • Start date Start date
G

Gabe Jahn

Basically I've used the BitConverter to convert a byte[]
into a string. Now how do I convert it back to a byte[]?
Hopefully without creating my own algorithm to accomplish
this?

Thanks...
 
Gabe Jahn said:
Basically I've used the BitConverter to convert a byte[]
into a string. Now how do I convert it back to a byte[]?
Hopefully without creating my own algorithm to accomplish
this?

With BitConverter.ToString you'll have ended up with a dash-separated
hex value list. I don't know of an easy way of reversing that. (Well,
"one line" - it's not that hard to reverse it really.)

If you change to use Convert.ToBase64String then you can easily reverse
it using Convert.FromBase64String and it's slightly more compact as
well :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top