I have the following floating point numbers, all with 2 decimal places:
2.47
57.83
93.92
119.20
I want to output these numbers as follows:
2.47
57.83
93.92
119.20
How can I achieve that in C#, if the font is not monospaced?
Edit:
Or is there any invisible character that occupies the same amount of horizontal space as a digit?
Try string.Format("{0,6:F2}", number).
Since C# 6.0 from 2015, you can write $"{number,6:F2}" instead.
I've never used Gtk# before, but a quick Google search revealed this.
label.Justify = Justification.Right;
This is a much simpler and more reliable strategy than trying to manipulate the string to the proper width.
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