Click here to Skip to main content
15,039,359 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello.

Would it be possible
to hold an object reference
in the safe class context of C#, please ? :-O :)

C#
public abstract class WizardPage : UserControl
{
    private Wizard wizard;

    public WizardPage(ref Wizard wizardRef)
    {
        wizard = wizardRef; // hmmm... is it just a copy now ? :)
    }

    public abstract void OnBack();
    public abstract void OnActivate();
    public abstract void OnNext();
    ...
}

Thank You !
Posted
Updated 27-Jul-10 5:09am
v2

If Wizard is a class (reference type) then you can just pass it without the ref.
C#
private Wizard wizard;

public WizardPage(Wizard wizard)
{
    this.wizard = wizard;
}
   
Comments
Eugen Podsypalnikov 28-Jul-10 3:20am
   
Reason for my vote of 5
Was a base to understand, that the this.wizard is a reference after the "=" operation (not an instance as after the "= new" operation) !!
   
Comments
Eugen Podsypalnikov 28-Jul-10 3:18am
   
Reason for my vote of 5
It was very usefull for me
Thank you ! :)

Understood :-D :
{
  object o1 = new object(); // o1 is a reference to an real instance in the memory

  object o2;                // o2 is a empty reference yet

  o2 = o1;                  // o2 is a reference to the same instance
                            // referenced by o1, not a reference to an own instance (!!) 

}
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900