Results 1 to 2 of 2

Thread: constructors constructing classes

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    constructors constructing classes

    hi.

    in .NET 1.1 i didnt have this problem. im using .NET 2.0 now, perhaps something im doing wrong.

    say I have 3 classes.

    ClassA
    ClassB
    ClassC

    one doesnt need to know about each other. so when constructing B, B knows nothing bout A, but A does as its constructing it. The same thing with Class C. so:

    ClassA -> ClassB
    ClassB -> ClassC

    now, since ClassC may require some objects from ClassB, which has objects from ClassA, ClassB passes them to the ClassC Constructor but it shows them as null, except for ClassA (ClassB gets ClassA and shows it as a proper class even though ClassB is being constructed from ClassA Constructor)

    After some "looking" into, I noticed that the objects will NOT be null when the constructors have been completed.

    but then, when is the best time to set these objects/properties after construction of each class?

    I hope you see my point.

    in .NET 1.1 I could do:

    Code:
    //ClassA
    this.ClassB = new ClassB(this);
    
    
    //ClassB
    
    this.classB = incomingValue;
    this.ClassC = new ClassC(this, this.classB); //classB is null at this point

    MVP 2007-2010 any chance of a regain?
    Professional Software Developer and Infrastructure Engineer.

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: constructors constructing classes

    hmm disregard this

    shouldve added another parameter to include the class itself of which it is constructing from, i.e:

    ClassC (classB, classA)

    MVP 2007-2010 any chance of a regain?
    Professional Software Developer and Infrastructure Engineer.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width