BitConverter and back again?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gabe Jahn

    #1

    BitConverter and back again?

    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...
  • Jon Skeet

    #2
    Re: BitConverter and back again?

    Gabe Jahn <gjahn@algor.co m> wrote:[color=blue]
    > 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?[/color]

    With BitConverter.To String 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.ToBase6 4String then you can easily reverse
    it using Convert.FromBas e64String and it's slightly more compact as
    well :)

    --
    Jon Skeet - <skeet@pobox.co m>
    Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

    If replying to the group, please do not mail me too

    Comment

    Working...