如何在datagridview中综合双重类型的值



我想知道如何将双重类型的Datatable值归为两个小数,我尝试了下面的方式,但它们两个都不适合我,我做错了吗?

{ DataRow newRow = informationTable.NewRow();
                string typeColumn = material.Name.Replace(',', ':');// store element Id value             
                double gvolColumn = quantity.GrossVolume;// store gross volume value             
                double nvolColumn = quantity.NetVolume;// store net`enter code here` volume value             
                double gareaColumn = quantity.GrossArea;// store gross area value             
                double nareaColumn = quantity.NetArea;// store net area value             
                String.Format("{0:0.00}", gvolColumn);
                String.Format("{0:0.00}", nvolColumn);
                String.Format("{0:0.00}", gareaColumn);
                Math.Round(nareaColumn, 2);
  // set the relative information of current element into the table.
                newRow["Element Type"] = typeColumn;
                newRow["Gross volume"] = gvolColumn;
                newRow["Net volume"] = nvolColumn;
                newRow["Gross area"] = gareaColumn;
                newRow["Net area"] = nareaColumn;
                informationTable.Rows.Add(newRow);
}

您应该将值设置为变量:

   nareaColumn = Math.Round(nareaColumn, 2);

最新更新