In the below code sample, what does {0:X2}
mean? This is from the reflection section of the MCTS Application Development Foundation book (covering dynamic code, etc.).
foreach(Byte b in body.GetILAsBodyArray()) { Console.Write("{0:X2}", b); }
This uses the same format as String.Format(). Check out the following reference:
http://msdn.microsoft.com/en-us/library/fht0f5be.aspx
Beware the length specified is not respected if the number is too large to fit the length.
long a = 123456789; Console.Write("{0:X2}", a); -> 75BCD15
This is especially important if you want to show negative hex numbers where all the high bits are set to 1's.
long a = -1; Console.Write("{0:X2}", a); -> FFFFFFFFFFFFFFFF
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With