Reputation: 1151
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
Upvotes: 1
Views: 1163
Reputation: 137148
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.
Upvotes: 2