String formatting
-
In C++, if you write the following:
printf("Number: 0x%04X", 1);
The output will be:
Number: 0x0001
As one can see, the number is prepended with a zeros. How do you achieve the same with C#?
-
In C++, if you write the following:
printf("Number: 0x%04X", 1);
The output will be:
Number: 0x0001
As one can see, the number is prepended with a zeros. How do you achieve the same with C#?
Have a look at the NumberFormatInfo class. typically it it would be:
Console.WriteLine("Number: 0x{0}", 1.ToString("X4"));
output Number: 0x0001 WebBoxes - Yet another collapsable control, but it relies on a "graphics server" for dynamic pretty rounded corners, cool arrows and unlimited font support. -
Have a look at the NumberFormatInfo class. typically it it would be:
Console.WriteLine("Number: 0x{0}", 1.ToString("X4"));
output Number: 0x0001 WebBoxes - Yet another collapsable control, but it relies on a "graphics server" for dynamic pretty rounded corners, cool arrows and unlimited font support.tx it worked
-
Have a look at the NumberFormatInfo class. typically it it would be:
Console.WriteLine("Number: 0x{0}", 1.ToString("X4"));
output Number: 0x0001 WebBoxes - Yet another collapsable control, but it relies on a "graphics server" for dynamic pretty rounded corners, cool arrows and unlimited font support.Or in one step :- inx x = 100; System.Console.WriteLine("Number is 0x{0:X4}", x);
-
Or in one step :- inx x = 100; System.Console.WriteLine("Number is 0x{0:X4}", x);
John Burton wrote: System.Console.WriteLine("Number is 0x{0:X4}", x); Yeah I always forget about that...:omg: WebBoxes - Yet another collapsable control, but it relies on a "graphics server" for dynamic pretty rounded corners, cool arrows and unlimited font support.