I am attempting to use string.Format to include a currency symbol and seeing an unexpected result.
See the following:
var textToReplace = "Final price is {0} {1}";
var output = string.Format(textToReplace, "Include MAD currency symbol here", "123.90");
output.Dump();
// Currency symbol is د.م.
Final price is د.م. 123.90
Strangely as I type this question, the SO question area automatically switch the currency symbol position with amount. Its bit hard to explain, try it yourself.
I would like to see the currency symbol followed by the amount. However I see the the amount followed by the currency symbol.
How can I explain this behaviour?
The problem you're facing is that the symbol is RTL. The position is correct, but it gets rendered in the other way. You could try to add the Unicode \u200E
.
This will mark that the character should be Left-to-Right
for example:
var textToReplace = "Final price is {0} {1}";
var output = string.Format(textToReplace, "Include MAD currency symbol here\u200E", "123.90");
output.Dump();
Example: https://dotnetfiddle.net/zVegfA