Skip to main content
cleaned up source, added link
Source Link
user7116
  • 63.7k
  • 17
  • 145
  • 173

Cast and use composite formattingcomposite formatting:

char ch = 'A';
string strOut = String.Format("\\x@"\x{0:x4}", (ushort)ch);

Cast and use composite formatting:

char ch = 'A';
string strOut = String.Format("\\x{0:x4}", (ushort)ch);

Cast and use composite formatting:

char ch = 'A';
string strOut = String.Format(@"\x{0:x4}", (ushort)ch);
Source Link
user7116
  • 63.7k
  • 17
  • 145
  • 173

Cast and use composite formatting:

char ch = 'A';
string strOut = String.Format("\\x{0:x4}", (ushort)ch);