1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
string[] concat = new string[10];
int somme=0x00;
string input ="0013A200";
for (int i = 0; i < input.Length; i = i + 2)
{
int j = 0;
concat[j] = (input[i].ToString() + input[i + 1].ToString());
MessageBox.Show("concat" + concat[j]);
//affichage: 00 13 A2 00
string hexOutput = String.Format("0x{0:X}", concat[j]);
MessageBox.Show("hexoutput" + hexOutput);
//0x00 0x13 0xA2 0X00
int hex = int.Parse(hexOutput);
MessageBox.Show("hex=" + hex);
//affichage: erreur: format de la chaine d'entrée est incorrecte
j++;
somme +=hex;
} |
Partager