1

I need to format Gtotals output to currency how can I accomplish this. I just grabbed a quick snippet from my code it is not in order.

 string Lname, Fname, Depart, Stat, Sex, Salary, cDept, cStat, cSex;
 double Gtotal;


 fields = recordIn.Split(DELIM);
                    Lname = fields[0];
                    Fname = fields[1];
                    Depart = fields[2];
                    Stat = fields[3];
                    Sex = fields[4];
                    Salary = fields[5];

                    Fname = fields[1].TrimStart(null);
                    Depart = fields[2].TrimStart(null);
                    Stat = fields[3].TrimStart(null);
                    Sex = fields[4].TrimStart(null);
                    Salary = fields[5].TrimStart(null);

                    Gtotal = double.Parse(Salary); //convert this to currency? ie. $56,000
Michael Quiles
  • 1,131
  • 3
  • 24
  • 41

2 Answers2

2

Use the "C" format specifier.

Gtotal.ToString("C0");

will format the value with no decimal places. You can also use the culture info to override the current culture to get different currency symbols if necessary.

Source

ChrisF
  • 134,786
  • 31
  • 255
  • 325
0

Gtotal.ToString("C")

Femaref
  • 60,705
  • 7
  • 138
  • 176