Convert from string ascii to string Hex
ascii, c#, hex, string
Solution
string str = "1234";
char[] charValues = str.ToCharArray();
string hexOutput="";
foreach (char _eachChar in charValues )
{
// Get the integral value of the character.
int value = Convert.ToInt32(_eachChar);
// Convert the decimal value to a hexadecimal value in string form.
hexOutput += String.Format("{0:X}", value);
// to make output as your eg
// hexOutput +=" "+ String.Format("{0:X}", value);
}
//here is the HEX hexOutput
//use hexOutput
Problem
Suppose I have this string ``` string str = "1234" ``` I need a function that convert this string to this string: ``` "0x31 0x32 0x33 0x34" ``` I searched online and found a lot of similar things, but not an answer to this question.