D
David
Hi all,
This is the first time I have tried this and so far, it seems to work, but
for me, unexpectedly.
I have code similar to...
namespace Dave.MyGenerator
{
public class FirstClass
{
... Do stuff here
variables
properties
functions
public class SubClass
{
public void NewFunctionInSubClass()
{
}
}
}
}
When I access it, I would have thought that it would be something like...
FirstClass myClass = new FirstClass();
// Set properties, var, run functions etc.
myClass.SubClass mySub = new myClass.SubClass();
however, this is not so. It can only be called from...
FirstClass.SubClass mySub = new FirstClass.SubClass();
Why is this?
What I am aiming for is that SubClass can only be instantiated whilst the
FirstClass is running. With the above example, is this true? Can the
SubClass be instantiated outside of FirstClass?
On another note, from within the subclass, I want to be able to transfer
content to the parent class. This will usually be a stringbuilder string,
but could just as easily be numeric, datasets etc. How would I do this?
On a final note, when I instantiate a class, when I have done with it, how
do I clean up, or does it just go into garbage collection when it goes out
of scope?
Thanks for your assistance.
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
This is the first time I have tried this and so far, it seems to work, but
for me, unexpectedly.
I have code similar to...
namespace Dave.MyGenerator
{
public class FirstClass
{
... Do stuff here
variables
properties
functions
public class SubClass
{
public void NewFunctionInSubClass()
{
}
}
}
}
When I access it, I would have thought that it would be something like...
FirstClass myClass = new FirstClass();
// Set properties, var, run functions etc.
myClass.SubClass mySub = new myClass.SubClass();
however, this is not so. It can only be called from...
FirstClass.SubClass mySub = new FirstClass.SubClass();
Why is this?
What I am aiming for is that SubClass can only be instantiated whilst the
FirstClass is running. With the above example, is this true? Can the
SubClass be instantiated outside of FirstClass?
On another note, from within the subclass, I want to be able to transfer
content to the parent class. This will usually be a stringbuilder string,
but could just as easily be numeric, datasets etc. How would I do this?
On a final note, when I instantiate a class, when I have done with it, how
do I clean up, or does it just go into garbage collection when it goes out
of scope?
Thanks for your assistance.
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available