Click here to Skip to main content
15,893,663 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Explain me when a class is loaded waht the process take place
Posted
Comments
Sergey Alexandrovich Kryukov 21-Sep-11 20:48pm    
Not quite correct, but interesting question, in fact. I voted 4.
--SA

Please look into this article here: http://msdn.microsoft.com/en-us/magazine/cc163791.aspx[^].

Best regards,

—MRB
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 21-Sep-11 20:49pm    
Thank you for referencing interesting article, my 5.
Nevertheless I tried to answer the question directly. I think it's somewhat interesting, please see.
--SA
A class is not "loaded" at all. It statically exists in an assembly after it is loaded. No part of code of the loaded assembly is involved in it. The class statically exists in an assembly in the same way as any part of the code.

At the same time, if a class has static members which need initialization, the initialization code is pre-elaborated when an assembly (or rather a process using assembly) is loaded. By the way, this creates an interesting case of the code which runs before application entry point (Main) is started.

So, the term loaded is not applicable to classes. Main activity takes place when an instance of the class is created. This is called construction (a case of initialization), not loading, and this is not what you have asked about.

—SA
 
Share this answer
 
v2

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