viewability of objects

A

AMP

Hello,
I have a asked this before with no response, I am looking for a good
book, article,post, anything, that explains all the ways you can pass
and view class instances.
I know how to do it by passing instances in constructors and I can do
this safely, and create fields in the receiving class, from the passed
object but i know there are other ways.
I'm looking for a good set of best practices to use when creating and
referencing instances.
Thanks
 
A

AMP

You got a response.  The response was "I don't know of such a book".  You  
can safely assume that if someone did know of such a book, they would have  
said so.


There is nothing special about the arguments to constructors.  They work  
just like any other variable, in that there are rules for assignment,  
scope, use, etc., and you use them for references to objects in the same  
way you'd use any other variable for references to objects.


Unfortunately, the question is really too broad to be of any use.  
Alternatively, there is only one "approved" way of doing what you're  
asking, and so the idea of "best practices" just doesn't make any sense.

If you want to create an object, you use the "new" operator.  Period.  
That's the final word, at least until you are expert enough in the use of 
.NET to be using reflection to bypass the language entirely.

If you want to maintain a reference to an instance, you have to store that  
reference in a variable you can use.  Period.  That's even more the final  
word than the final word about creating an object.

These are operations that are so fundamental to the language that there  
really isn't any point in having a discussion about them.  You perform  
those operations in the way that the language provides for you, and it  
always works that way.

Pete

Pete,
I'm just overcomplicating things.
Thanks for your help, always.

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top