Glenn

Glenn

  • NA
  • 10
  • 0

String to Byte

Jan 30 2008 10:25 AM
Hello,

I am working on program to interact with a custom Ethernet based hardware i made. The program is suppsoe to take the memory address i enter and the hex file i specify and then send it to the device. Basicly its a ethernet programer.

Problem i am running into is when i call out the memory address. A example address on this device would be 0052C2679005. the code i am using take 2 pairs of characters converts them into a byte value then store it a byte[] array waiting to be sent the device. everything works fine until it gets to the C2 value. I receive a "Inproper format error" i guess Convert.ToByte() doe snot like that value.

Here the code
int i = 0;
int b = 0;
while (i < address.Length)
{
    string byteval = support.Substring(i, 2);
    value = Convert.ToByte(byteval);
    i += 2;
    b++;
}

Is there a different way of doing this or did i do somthing wrong? I know when i use Encoding.ToBytes() it takes each character by its self and converts it to a byte which is not what i want.

Answers (1)