Reputation: 12255
Ok still learning here. If I have one form calling another form like below (only the code for the second form is listed) where the parent form is ParentForm and I make a private member _parentForm in teh child form (frmViewPastMeasures
) so I can use it all over my child form class. If when I call _parentForm.Method() from my child form and that method is trying to change properties in the original parent form...are those properties affected in the same parentform I called from? Does _parentForm = parentForm;
link _parentForm
to the exact same object as parentForm
? Is the only time when that would not be the case be when I use the new
keyword? I just trying to change properties from an outside form and I want to make sure I'm actually accomplishing this correctly.
namespace Photometer
{
public partial class frmViewPastMeasures : Form
{
private frmPhotometer _parentForm;
public frmViewPastMeasures(csFilter activeFilter, csInitialUsageSettings InitialUsageSettings, frmPhotometer parentForm)
{
_parentForm = parentForm;
}
private someOtherMethod()
{
_parentForm.method();
}
}
}
Upvotes: 0
Views: 47
Reputation: 99957
Yes, if you assign an object reference to a variable, that variable will point to the exact same object as the one to which the assigned reference pointed.
Upvotes: 1