[Solved] ASP.NET C# help me about sum or minus in amount


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

solved ASP.NET C# help me about sum or minus in amount