Ok time for the 2nd dumb question of the day that I should probably already know the answer too..

I have string.Format(" {0, -22} | {1, 5} of {2, -5} | {3, 5}% | where {3} is a double that is being used for a percentage.

The longest allowed format is 5 characters so capable of support something like 99.99

I currently use string.Format("{0:#.00}", x) for the number going into there which works fine for say 64.29

However for other numbers it doesn't display cleanly.

I want to be able to have like:
100%
90%
90.8%
80.70%
1%
1.5%

So basically looking for a more flexible formatting pattern to put instead of {0:#.00}

I think you're looking for:

string.Format("{0:#.##}", x)

Docs

Solved

Have you tried:

String.Format("{0:#.##}", x)

I hadn't tin and it was the solution, Prit beat you too it

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.