|
-
Aug 21st, 2012, 05:29 PM
#8
Re: Using New Keyword
That's still not right. The object doesn't exist until somebody creates an instance of it. There are a few types of objects, such as forms, where MS has created default instances of them, so that the instance is created for you and it looks like it was always there. Another type of object where that appears to be the case is objects that implmenet the Singleton pattern where you have a Shared instance accessible through a private constructor such that it looks like it was always there. It isn't though, it just has a private constructor and an accessor that creates the instance the first time you try to access it. Those are kind of rare, though.
In all classes, you have a definition of the class, which defines the members, constructors, properties, events, methods, and so forth. That defines the object. In every single case, somebody has to explicitly create an instance of the object before it can be used. There are ways to fool people into thinking that an instance was already there and didn't have to be created, but that is all just smoke and mirrors. Every object has to be created with New before it can be used, though you may not always see the use of the New keyword because something could have been done to hide it from you.
Every object has to be instantiated before it is used. You aren't making copies unless you explicitly call a Copy or Clone method. All you are doing is creating instances of the object.
My usual boring signature: Nothing
 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|