How do i get (is it possible to) a reference to the class that creates an instance of another class.

Posted by Cadde on Stack Overflow See other posts from Stack Overflow or by Cadde
Published on 2010-05-20T08:04:03Z Indexed on 2010/05/20 11:00 UTC
Read the original article Hit count: 141

Filed under:
|
|

Odd situation... I need to create a new instance of a class that needs a member of the calling class. But i can't pass a reference to the calling class through the constructor.

The solution i am looking for is something like this:

Public Class ChildClass
    Public Sub New(args)
        _MyMember = GetMemberFromCallingClass()
        ...
        ...
    End Sub
End Class

I want this to work without having to manually pass any references or variables from the calling class to the new instance of ChildClass.

Is this possible and if so, what should i look at to make this part of my code.

© Stack Overflow or respective owner

Related posts about vb.net

Related posts about class