Of course not. All the instances are different. Each one might have
different properties set, etc, and that woudl make it behave differently.
If all instances of the same class, were actually just one instance
internally, then nothing would ever work. Imagine having 2 string
variables - but then somehow internally, .NET would treat them as one? How
would that work?
If the methods in your class don't depend on class state, and just on the
arguments to each of the methods, then you can make them all Shared. This
means you call the method through the class name itself, as opposed to
through an instance of that class. That means that no instance of the class
is ever instantiated, and you are not wasting resources by creating objects
that don't really need to be there.
"Tom" <to*@nospam.com> wrote in message
news:On**************@tk2msftngp13.phx.gbl...
I have a main VB.NET program which instantiates a number of other VB.NET
DLLs. This DLLs all use routines from a 'base' DLL (which contains a
number of common routines); so currently I reinstantiate that 'base' DLL in every
one of my called DLLs.
The question is: Would it be better if I instantiated the 'base' DLL in
the main program, then passed a reference of the 'base' to each of my other
DLLs? Or is .NET smart enough to use same copy of the 'base' DLL when it
gets instantiated in each of my DLLs? (in other words, even though the
same 'base' DLL is instantiated many times in different DLLs, VB.NET keeps only
one copy in memory of the 'base' DLL and they all share that copy).
Just wondering if going through the work of passing a reference to my
'base' DLL is worth it.... Thanks.
Tom