In short, I am using C# and I have some strings like:
00 fe ff 01 ff ff ff 01 00 01 00 00 02 01 00 ff 54 5b
or without spaces:
00feff01ffffff0100010000020100ff545b
I would like these to be formatted as hex values like the following string:
\x00\xfe\xff\x01\xff\xff\xff\x01\x00\x01\x00\x00\x02\x01\x00\xff\x54\x5b
I have spent today trawling through StackOverflow and some other places and tried a number of things, but I can't seem to get my output string formatted in this way when using variables.
Just to elaborate on the variables I would use to make up this string:
string maincode = "00feff01ffffff0100010000020100";
string parameter = "ff";
string checksum = "545b";
//this is to put the three variables back together as a single string after all calculations are complete. Will display as this 00feff01ffffff0100010000020100ff545b
string output = maincode + parameter + checksum;
From the output variable step, I then need to add the \x
before every byte to format a string that will be in hex format to send to the device I am controlling.