Bruce 0

Bruce 0

  • NA
  • 3
  • 0

passing objects as parameters to forms

Mar 21 2005 4:14 PM
I'm having the following problem: I am passing several objects to the constructor of a form so that the form can modify the contents of these objects based on user input. Since these objects have to be available to several of the methods within the form class and not just to the constructor I am (in the constructor) assigning each of the object parameters to private object variables within the form class (e.g. ParameterClassType localObjectVariable = parameterName). This allows the various methods in my form object to manipulate the original objects being passed in as parameters (these objects are created in another form). Here's the problem: when I kill my new form using form.Close(), the original objects are wiped clean of all of their data. I presume this is because the form's object variables are references to the original objects; the MSDN info on form.close() says that this closes all of the form's resources, which I assume includes any local objects variables. So I am assuming that doing this is wiping out the original objects by reference action. Is there any way I can break the reference association between my form's object variables and the parameter objects to which they refer before invoking form.Close()? I can't seem to find a way.

Answers (2)