problem with increment decimal value
-
i have datagrid contains 4 columns , one of them takes decimal datatype i want to increment this value each time to get the sum string name; decimal price, due; int count; name = txtSelectedItem.Text; price =decimal.Parse( lblPrice.Text); count =int.Parse( txtUnitOrder.Text); due = decimal.Parse(lblDue.Text); DGSelectedItems.Rows.Add( name,price,count,due); decimal sum = due++; txtSum.Text = sum.ToString(); the value didn`t incremented but replaced regards in advance
-
i have datagrid contains 4 columns , one of them takes decimal datatype i want to increment this value each time to get the sum string name; decimal price, due; int count; name = txtSelectedItem.Text; price =decimal.Parse( lblPrice.Text); count =int.Parse( txtUnitOrder.Text); due = decimal.Parse(lblDue.Text); DGSelectedItems.Rows.Add( name,price,count,due); decimal sum = due++; txtSum.Text = sum.ToString(); the value didn`t incremented but replaced regards in advance
Mr.Kode wrote:
decimal sum = due++;
due is incremented after is is assigned to sum... you want...
decimal sum = ++due;
That should fix it.Matthew Butler