How to format the number in hexadecimal format with the prefix "0x"?
For example:
int space = 32; MessageBox.Show(space.ToString("'0x'X4"));
I clicked on this link: Custom Number Format Strings http://msdn.microsoft.com/en-us/library/0c899ak8.aspx Literal Line Separator: Indicates that private characters should be copied to the result string without changes. But this does not work for "X4" (it works for "#"), something is strange.
I use it in DataGridView.DefaultCellStyle.Format, so I can not use:
"0x{0:X4}", space
Thanks. Peter
c # format hex
Peter Lee
source share