0

我需要将此 197000.99996 更改为 $197,001

我知道我需要使用 {0:C}

但是当我使用数组时我不知道该怎么做,下面是代码

public ActionResult getAjaxSCs(string PA = null, float AmountList = 0)
        {

            if (PA != null)
            {

                var SCList = from x in db.NDE_Actuals_Web                             
                             where x.PA == PA                             
                             group x by new { x.SPEND_CATEGORY, x.ACCOUNTING_PERIOD} into scgroup                             
                             select new { spend_category = scgroup.Key.SPEND_CATEGORY, accounting_period = scgroup.Key.ACCOUNTING_PERIOD, amount = scgroup.Sum(x=> x.Amount)};

                SCList = SCList.OrderBy(x => x.spend_category);

                Dictionary<string, double[]> SCRow = new Dictionary<string, double[]>();
                double[] SCContent = new double[12];
                string lastSpendCategory = null;
                foreach (var item in SCList)
                {
                    if (lastSpendCategory != item.spend_category)
                    {
                        SCContent = new double[12];
                    }

                    int accounting_period = int.Parse(item.accounting_period) -1;
                    SCContent[accounting_period] = (double)item.amount;
                    SCRow[item.spend_category] = SCContent;
                    lastSpendCategory = item.spend_category;
                }

                return Json(SCRow, JsonRequestBehavior.AllowGet);

            }
            return View();
        }

我需要转换 SCRow,以便它以货币格式发送值并舍入小数点。谢谢你的帮助!

4

0 回答 0