My program in a nutshell is reading a text file, outputting it to the console screen one character at a time, and then writing the characters as its read as hex pairs.
I'm calling this method in a loop: WriteByte((char)ch, ref writer);
(passing in the character, and a reference to the output file, which is a StreamWriter)
Here is the method:
static void WriteByte(char w, ref StreamWriter writer)
{
writer.Write(w);
}
I need to write the character to that output file as 2-digit hex, with a space in between each pair. How to I format the char to be a hex digit?