Convert int to Hex

Asked

Viewed 1,272 times

1

what I want to do is possible? convert the value variable to Hex.

private void button1_Click(object sender, EventArgs e)
{
        int value = 255;
        byte[] buffer = new byte[5];
        buffer[0] = 0xff;
        buffer[1] = value; //eu preciso converter esse value para hex.
                           //igual ao buffer[0] , tem como?    
}
  • 2

    Explain better what you want to do, do you want to print the value in hexadecimal? Hexadecimal is just a representation, number is number, no conversion required.

  • It would be the same as here: http://answall.com/q/181044/101

  • thanks for the reply, I managed to do what I wanted.

2 answers

1

int intValue = 182;

string hexValue = intValue.ToString("X");

int intAgain = int.Parse(hexValue,System.Globalization.NumberStyles.HexNumber);

0

Browser other questions tagged

You are not signed in. Login or sign up in order to post.