Basic question about ref and variables

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a very basic question about ref and variables

If I create a variable such a

private Form1 mform

and then assign mform a variable passed by reference such a

Form2(ref Form1 f){mform = f;

is mform assigned to a reference/pointer pointing to the object referenced by f or does the clr copy the object pointed to by f into mform (I assume the former)? I'm working on an application that will have an unlimited hierarchy of objects and would like to use references/pointers instead of array indexes to provide access to parent objects

Thanks

Paul K
 
Paul,
is mform assigned to a reference/pointer pointing to the object referenced by f

Yes, assuming Form1 is a reference type (System.Windows.Forms.Form
is).



Mattias
 
Oh yeah...duh. I was confusing reference types and value types. Now that I've got my head out of the sand, I'll be able to get my application working correctly.

Thanks!

Paul K
 
Back
Top