1

I was trying to align doubles using string.format and display them on a tooltip.

I used: string.Format("{0,15:N2}", number);

but the results come out as:

   1234.56
    00.00

It seems some of the numbers are narrower than the space. Does anyone know how to solve this problem?

Thanks!

1 Answer 1

4

Use a fixed-width font such as Courier New or Consolas if you want all the individual digits to line up.

Sign up to request clarification or add additional context in comments.

1 Comment

No – numbers line up just fine in most fonts because they’re all the same width (new style figures). The problem is getting the decimal points below each other which isn’t possible using only string formatting.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.