Easiest way to convert a byte[] to a hex string

by JasonRShaver 22. April 2009 16:57

 Sometimes you just want to convert a byte array to an easy to use string.  You could use Base64 strings, but then you have to read and enter upper and lower case chars without error.  I find it easier to just convert it to a hex string (0-9, A-F).  Turns out Microsoft made an easy way to do this.

Enter the 'System.Runtime.Remoting.Metadata.W3cXsd2001' namespace (part of the core lib).

        private String _ConvertByteToString(byte[] input)

        {

            SoapHexBinary hexBinary = new SoapHexBinary(input);

            return hexBinary.ToString();

        }

        private byte[] _ConvertStringToByte(String input)

        {

            SoapHexBinary hexBinary = SoapHexBinary.Parse(input);

            return hexBinary.Value;

        }

Tags:

Blog

New personal best 5k time, 27:57

by JasonRShaver 19. April 2009 16:57

 At this years NCO Spring Ahead 5K, I just ran a 27:57, which is better then the 30:00 time I got last year at the same race (15th in my age group), AND better then 28:07 I got as my previous personal best.

 5k Race Results

Place Div Sex Name                  No.   S Age  City         St Time    Pace  
===== === === ===================== ===== = ==== ============ == ======= =====
100   9  72 JASON SHAVER           1335 M   28 BOLINGBROOK  IL   27:57  9:00 
172   5  65 KELLY SHAVER           1334 F   27 BOLINGBROOK  IL   30:17  9:45 
215  18 120 JORDAN DUERKSEN        1423 M   38 PLAINFIELD   IL   32:21 10:25

382 people ran the 5k

Tags:

Blog

About the author

I am a software developer working for Microsoft in Redmond, WA.  In addition, my wife and I own TTXOnline, what is likely the 3rd largest table tennis store in the US.

Month List

Page List