I have this code that computes a summary of 2 multiplied columns of all rows in a datagridview.
private void vypocti_odvody(int price, int vat, int tot_rows2) { try { double outVal = 0; foreach (DataGridViewRow row in dataGridView1.Rows) { outVal = outVal + (Convert.ToDouble(row.Cells[price].Value)/100) * Convert.ToDouble(row.Cells[vat].Value) + (Convert.ToDouble(row.Cells[price].Value)); }
How can I improve decimal positions? Now the result looks like this: 123.5484250 I would like to have only 2 decimal positions with the result, for example, 123.55.
Sorry for my poor english. I hope the “decimal position” is the expression for the word that I really mean. In case I made an example for a better understanding.
Thank you all for your time, comments and answers.
source share