troubleshooting Question

C# string to byte function

Avatar of Larry Brister
Larry BristerFlag for United States of America asked on
C#ASP.NETWeb Services
5 Comments1 Solution17 ViewsLast Modified:
In I converted a function and got the code below

I am getting an error on this line
 yKey = new byte[sHex.Length / (double)2 - 1 + 1];

  private byte[] ConvertHex(string sHex)
    byte[] yKey;

        yKey = new byte[sHex.Length / (double)2 - 1 + 1];
        int i = 0;
        int j = 0;

        while (j < yKey.Length)
            yKey[j] = Convert.ToByte(sHex.Substring(i, 2), 16);
            i += 2;
            j += 1;
    catch (Exception e)
        throw new Exception(e.Message, e);

    return yKey;
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros