[Mono-devel-list] Brazilian currency in Mono

Jurandy Martins Soares Junior jurandy at lsd.ic.unicamp.br
Wed Oct 6 14:46:38 EDT 2004


Sorry! I made some corrections in my code... ;-)

> > >I've tried to make Mono print a >>double<< as currency, using the format
> > >of my country. See code below:
> > >
> > >     double total = 7.50;
> > >     IFormatProvider formato = new CultureInfo("pt-br", true);
> > >     msg.Text = String.Format("{0:c}", total);
> > >
> > >It prints "R$8" rather than "R$7,50".
> > >It rounds the value. In brazilian portuguese comma is the separator.
> >

Meanwhile, I'm using code below, that worked:
  using System.Globalization;
  [...] 
     double total = 7.50;
      IFormatProvider formato = new CultureInfo("en-US", true);
      String aux = total.ToString("c", formato);
      aux = aux.Replace(",", "-");
      aux = aux.Replace(".", ",");
      aux = aux.Replace("-", ".");
      aux = aux.Replace("$", "R$");
  [...]
  
Regards,
Jurandy Martins



More information about the Mono-devel-list mailing list