我使用金额的datagridview的细胞中,这种代码。总和datagridview的细胞逗号生成格式异常
int sum = 0;
for (int i = 0; i < dataGridView1.Rows.Count; ++i)
{
sum += Convert.ToInt32 (dataGridView1.Rows[i].Cells[1].Value);
}
int count_row = dataGridView1.Rows.Count;
label1.Text = (sum.ToString());
如果我只是使用数字,代码运行良好。然而,当我使用逗号,例如,1,34和2,20,它说,格式异常是未处理的。
如果将'1,332'转换为'Int32',你会发生什么? –
使用十进制不是int – Coding4Fun