I have a function to convert string to hex as this,
public static string ConvertToHex(string asciiString) { string hex = ""; foreach (char c in asciiString) { int tmp = c; hex += String.Format("{0:x2}", (uint)System.Convert.ToUInt32(tmp.ToString())); } return hex; } Could you please help me write another string to Binary function based on my sample function?
public static string ConvertToBin(string asciiString) { string bin = ""; foreach (char c in asciiString) { int tmp = c; bin += String.Format("{0:x2}", (uint)System.Convert.????(tmp.ToString())); } return bin; }
char=>int=>string=>uint=>uint(again?) … whoa! You’ve lost me there.ToUInt32that is doing the conversion to the hex, but it is actually thex2formatting specifier to String.Format. Unfortunately, I don't think there is ab8format specifier.