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 :)
 
Back
Top