The
dataSet
parameter is a reference to an object. The reference was passed by value and so changing it will not effect the original value. So the below code will only have effect inside the function and will not change the value of the
output
variable from the call
Test(output)
.
public void Test(DataSet dataSet)
{
dataSet = new DataSet();
}
But when use the statement
dataSet.Tables[0].Rows[0][0] = "value2";
inside the function you are changing the object being referenced by
dataSet
which changes the values in the object as expected.