Possible Duplicate:
Engineering notation in C#?
Whether a metric prefix is preferable to the scientific notation may be up for debate but i think it has its use-cases for physical units.
I had a look around but it seems .NET does not have anything like that built in, or am i mistaken about that? Any method of achieving that would be fine.
As a clarification: The goal is to display any given number as a floating point or integer string with a value between 1 and 999 and the respective metric prefix.
e.g.
1000 -> 1k
0.05 -> 50m
With some rounding:
1,436,963 -> 1.44M
Create an extension method for each numeric type. You would call ToStringMetric() for you custom formatting.
According to these SO Articles and to my own research, there is no native way to format numbers in metric units. You will need to write your own methods to parse the units and append the relevant metric measurement, such as for instance an expanded example of this interface tutorial at MSDN. You can also try to find a metric units coding library to use for development.
Try this out. I haven't tested it, but it should be more or less correct.