code_junkie

How do I convert C# characters to their hexadecimal code representation

Nov 13th, 2011
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.17 KB | None | 0 0
  1. char ch = 'A';
  2. string strOut = String.Format("\x{0}", Convert.ToUInt16(ch).ToString("x4"));
  3.  
  4. char ch = 'A';
  5. string strOut = String.Format(@"x{0:x4}", (ushort)ch);
Add Comment
Please, Sign In to add comment