Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

when we use classname.instance we get the object of teh class.i need to know the about the object creation.Is it created with teh new operator.

regards,
shefeek
Posted

1 solution

Yes.
—SA
P.S.: I failed to post the above with the error message 'The content is too short', so I need to write something else.

With C#, the object instance of the reference is always created on heap, but the reference itself is stored somewhere depending on the context: it can be instance member or static member or a stack variable. Even though the class can provide a static (factory method), its implementation ultimately always uses new.

(C++/CLI is the exclusion from this principle: it provides value semantic even for reference types. An object can be created either on heap with gcnew or it can be stored without the reference in data segment or stack.)

—SA
 
Share this answer
 
v2
Comments
Abhinav S 2-Aug-11 1:24am    
I removed my answer because it was similar to your answer. An instance is created using the new operator.

My 5 for your answer.
Sergey Alexandrovich Kryukov 2-Aug-11 1:46am    
Thank you, Abhinav.
--SA
Brij 2-Aug-11 1:26am    
Good Call. 5ed
Sergey Alexandrovich Kryukov 2-Aug-11 1:47am    
Thank you.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900