I encountered a bit strange behaviour that I could not understand I wonder if someone can help me understand it.
The follwing method recives an object array and make some changes in the array members
public static void adjustRow(object[] row, String column)
{
Double price ,units ,invest;
if (!(Double.TryParse(row[3].ToString(),out price)
& Double.TryParse(row[4].ToString(),out units)
& Double.TryParse(row[5].ToString(),out invest)))
return ;
switch (column)
{
case INVEST: row[4] = Math.Round(invest / price,2); break;
case UNITS:
case PRICE: row[5] = Math.Round(units * price,2); break;
}
}
the follwing method call the above method:
void editGrids_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
DataGridView gridView = sender as DataGridView;
DataTable source= null;
if (gridView != null)source = gridView.DataSource as DataTable;
if (source != null)
Systm.adjustRow(source.Rows[e.RowIndex].ItemArray,gridView.Columns [e.ColumnIndex].HeaderText);
}
I expected that the values in the input array will be changed outside of the first method scope as well but the actual result is that the values remain the same any explanation?
Thanks Eran