How to parse string to decimal with currency symbol?

后端 未结 2 1090
梦如初夏
梦如初夏 2020-12-11 14:57

I have no idea why this is not working:

string s = \"12,00 €\";
var germanCulture = CultureInfo.CreateSpecificCulture(\"de-DE\");
decimal d;
if (decimal.TryP         


        
相关标签:
2条回答
  • 2020-12-11 15:32

    Try this;

     string.Format(new CultureInfo("en-SG", false), "{0:c0}", 123423.083234);
    

    It will convert 123423.083234 to $1,23,423 format.

    0 讨论(0)
  • 2020-12-11 15:35

    Use NumberStyles.Currency instead of NumberStyles.AllowCurrencySymbol

    if (decimal.TryParse(s, NumberStyles.Currency, germanCulture, out d))
    

    and the output for you code would be:

    Decimal value: 12.00
    
    0 讨论(0)
提交回复
热议问题