Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Johannes Lantz 156 posts 838 karma points c-trib
    Jan 10, 2022 @ 12:25
    Johannes Lantz
    0

    Get currency symbol

    Hi!

    I am planing to have dropdown where you can select your desired currency. I would like to format it like this: EUR €. Is there a way to get the currency symbol? I have looked around a bit, but only manged to find the .FormattedAmount() wich won't quite work. Or do I have to do something janky like using .FormattedAmount() and then treat the value like a string to then get the symbol?

    //Johannes

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Jan 10, 2022 @ 13:59
    Matt Brailsford
    100

    Hi Johannes,

    If you want to format your prices everywhere as EUR € you could set this as your currencies format template in the currency settings with a value of EUR €{0:0.00} which I think should work meaning all prices coming from FormattedAmount() would be in this format.

    Alternatively, you'll have to get the culture info of the currency and then access the currency symbol from there

    var culture = CultureInfo.GetCultureInfo(cultureNameFromCurrency);
    var symbol = culture.NumberFormat.CurrencySymbol;
    

    Hope this helps

    Matt

  • Johannes Lantz 156 posts 838 karma points c-trib
    Jan 10, 2022 @ 14:14
    Johannes Lantz
    1

    Hi Matt!

    var culture = CultureInfo.GetCultureInfo(cultureNameFromCurrency);
    var symbol = culture.NumberFormat.CurrencySymbol;
    

    Did the trick! Thanks :)

    //Johannes

Please Sign in or register to post replies

Write your reply to:

Draft