Search code examples
asp.net-mvcmodel-view-controllerstring-formattingcurrencytostring

how do i delete extra zeros in mvc?


I'm taking DATA like 10.0000000000 but my real data 10,00
how can change this format ?

I'm using this code; item.sbirimfiyati = String.Format("{?}", item.cbirimfiyati);


Solution

  • You can use this custom code. This is working fine.

    double yourValue = 10.0000000000;
    int x = Convert.ToInt32(yourValue);
    string har = String.Format("{0},00", x); // output: 10,00