这是我的代码,出现未知错误:
private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
        for (int i = 0; i < dataGridView1.Rows.Count; ++i)
        {
            object a = dataGridView1.Rows[i].Cells["price"].Value;
            object b = dataGridView1.Rows[i].Cells["tedad"].Value;
            double aNumber = 0;
            double bNumber = 0;
            if (a != null)
                aNumber = Double.Parse(a.ToString());
            if (b != null)
                bNumber = Double.Parse(b.ToString());
            dataGridView1.Rows[i].Cells["total"].Value = aNumber * bNumber;
            dataGridView1.RefreshEdit();
        }
        decimal sum = dataGridView1.Rows.OfType<DataGridViewRow>()
           .Sum(row => Convert.ToDecimal(row.Cells["total"].Value));
        txtDate.Text  = sum.ToString();
像这样的错误意味着OfType():
“System.Windows.Forms.DataGridViewRowCollection”不包含“OfType”的定义,并且没有扩展方法“OfType”接受“System.Windows.Forms.DataGridViewRowCollection”类型的第一个参数 WindowsFormsApplication1test
