How do I convert hex values in a string to a number?
<p>I have some code that reads a string from the serial port, parses some values (in this case a representation of a high byte and low byte), I then swap them around and combine them so they are in the right order, then I want to convert the combined value to a decimal value.</p>

<p>I am having difficulty trying to convert the hex representation as a string to hex, then converting the result to decimal.</p>

<p>The code is here:</p>

<pre><code>private void OutputUpdateCallbackclusterTxtBox(string data)
{
string cluster;
string attribute;
string tempvalueHighByte;
string tempvalueLowByte;
string tempvalueHighLowByte; //switched around
int temporarytemp;



if (data.Contains("T00000000:RX len 9, ep 01, clus 0x0201") == true)//find our marker in thestring
{
    if (data.Contains("clus") == true)
    {
        int index = data.IndexOf("clus"); //if we find it find the index in the string it occurs
        cluster = data.Substring(index + 5, 6);  //use this index add 5 and read in 6 characters from the number to get our value
        attribute = data.Substring(index + 5, 1);
        cluster_TXT.Text = cluster; // post the value in the test box
    }
    if (data.Contains("payload") == true)
    {
        int index = data.IndexOf("payload"); //if we find it find the index in the string it occurs
        tempvalueHighByte = data.Substring(index + 20, 2);  //use this index add 20 and read in 2 characters from the number to get our value
        tempvalueLowByte = data.Substring(index + 23, 2);  //use this index add 23 and read in 2 characters from the number to get our value
        tempvalueHighLowByte =  tempvalueLowByte + tempvalueHighByte;


        ConvertToHex(tempvalueHighLowByte);

        temporarytemp= int.Parse(tempvalueHighLowByte);
        temperatureTxt.Text = ((char)temporarytemp).ToString(); // post the value in the text box
    }
</code></pre>
