[ad_1]
Try this:
var total = dataGridView1.Rows.Cast<DataGridViewRow>()
.AsEnumerable()
.Sum(x => x.Cells[3].Value.ToString() == "Credit"? int.Parse(x.Cells[2].Value.ToString()) : -(int.Parse(x.Cells[2].Value.ToString())))
.ToString();
textBox1.Text = total;
3
[ad_2]
solved ASP.NET C# help me about sum or minus in amount