I'm looking to format my int into strings that shorten the number. i.e.
1 -> 1
10 -> 10
100 -> 100
1000 -> 1K
1100 -> 1,1K
10000 -> 10K
11000 -> 10K
100000 -> 100K
1000000 -> 1M
etc...
I tried some code snippets I found already on stack overflow such as
public class Test
{
public string MyMethod(int num)
{
if (num >= 1_000)
{
return (num / 1_000).ToString("0.#") + "K";
}
}
}
this worked to an extent, however, I'm not sure what the formatting "0.#" does and I can't find anything online to explain it. There are some further examples on the same post which cover some other formatting types such as "#,0K" but again, I don't know the difference so I can't customise these to how I like them.