static void Main(string[] args) { int n = -123; IFormatProvider fp = new IntHexFormatter.IntHexFormatter(); Console.WriteLine(string.Format(fp, "{0:X8} = {0:X4} = {0:H}", n)); Console.WriteLine(string.Format(fp, "{0:x8} = {0:x4} = {0:h}", n)); Console.WriteLine(string.Format(fp, "{0:x8} = {0:x4} = {0:h}", int.MinValue)); Console.ReadLine(); }
public void IntHexFormatterAssertTests() { IFormatProvider fp = new IntHexFormatter(); for (int i = -1023; i < 1024; i++) { Assert.AreEqual(string.Format(fp, "{0:H}", i), string.Format("{0:X8}", i)); } for (int i = -1023; i < 1024; i++) { Assert.AreEqual(string.Format(fp, "{0:h}", i), string.Format("{0:x8}", i)); } }
public string IntHexFormatterUsualTests(int number) { IFormatProvider fp = new IntHexFormatter(); return string.Format(fp, "{0:H}", number); }