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
    Oct 31, 2022 @ 14:31
    Johannes Lantz
    0

    Format space in price

    Hi!

    I was just curious if it's possible to remove the space when the amount goes up to thousands? So instead of 1 000 kr it becomes 1000 kr. It would be neat if I woulden't have to do this everytime:

    product.CalculatePrice().Formatted(0).WithTax.Replace(" ", "")
    

    //Johannes

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Oct 31, 2022 @ 14:39
    Matt Brailsford
    0

    Hi Johannes,

    This is defined by your currency and it's culture settings. By default it'll use the number formatting defined by it's given culture, but if you want, you can provide your own formatting string template in the currencies settings. Maybe a template like {0} kr would do the trick (or it may need some specific formatting opperators, see MSDN docs for more on that https://learn.microsoft.com/en-us/dotnet/api/system.string.format?view=net-6.0)

  • Johannes Lantz 156 posts 838 karma points c-trib
    Oct 31, 2022 @ 14:57
    Johannes Lantz
    100

    Hi Matt!

    {0:F0} kr solved it! I didn't know could do number formatting that way!

    Thank you!

    //Johannes

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Oct 31, 2022 @ 15:02
    Matt Brailsford
    0

    Awesome!

Please Sign in or register to post replies

Write your reply to:

Draft