Hey, I currently have a Currency Format method:
private string FormatCurrency(double moneyIn)
{
CultureInfo ci = new CultureInfo("en-GB");
return moneyIn.ToString("c", ci);
}
I'm looking to adapt this to shorten the string as the currency get's larger. Kind of like how stack overflow goes from 999 to 1k instead of 1000 (or 1.6k instead of 1555).
I imagine that this is a relativly easy task however is there any built in function for it or would you just have to manually manipulate the string?
Thanks
There is nothing built in to the framework. You will have to implement your own logic for this.
This question comes up fairly often - see the answers to this question (Format Number like StackoverFlow (rounded to thousands with K suffix)).
I would use the following to accomplish what you require, I don't think there is anything builtin to do this directly!
You may also want to round the result of moneyIn/1000 to 1 decmial place.
HTH
You will have to write your own function to do this. It isn't built into the default string formatting stuff in .NET.