A couple things I could think off of the top of my head, though I'm
not sure what the best implementation would be, in your case.

First possible method: You could have an overloaded constructor that
takes an object of Class A and stores it in a member variable in Class
B:

classA = new A();
classB = new B(classA);

classB would then be able to utilize whichever public methods or
members you've exposed in class A.

Second possible method: Have Class B be a nested class of Class A:

class A
{
...
   class B
   {
      // access all of class A's STATIC members
   }
}

There are a number of things you could do, but again, not sure of the
scenario in which you'd be using this.  I would personally opt for the
first method, just because I dislike nested classes, and having a
nested class do all sorts of stuff under the hood to its parent class
could easily get convoluted.

Just my two cents.

Josh

On Mar 29, 7:14 pm, Learner <[email protected]> wrote:
> Hi,
>
>   I have two classes say Class A and Class B. I am trying to find how
> do I get reference of Class A in Class B.
>
> I do not want to get a new instance of Class A. I want to be able to
> reference to the loaded instance.
>
> Class A
> {
>     ....
>    Class B clsb = New Class B();
>    clsb.DoSomething(int a, int b)
>
> }
>
> Class B
> {
> ...
>     public void DoSomething(int a, int b)
>      {
>        ....
>       //I want to be able to reference to the loaded instance of the
> Class A. (not a new instance)
>     }
>
> }
>
> Can some one please help me with this.
>
> Thanks,
> L

-- 
You received this message because you are subscribed to the Google
Groups "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML
Web Services,.NET Remoting" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/dotnetdevelopment?hl=en?hl=en
or visit the group website at http://megasolutions.net

Reply via email to