locked
Object life cycle RRS feed

  • Question

  • User1404574746 posted

    I have a classA which i have a static object A defined, and classA is inherited by my aspx pages. 

    Am doing this so instead of creating object A everytime the page is visited, it would basically be created once. 

    My question is: based on this design, does object A have a life cycle with the application such that it cannot be destroyed by a page (implicitly)

    Monday, October 28, 2013 6:45 PM

Answers

  • User-927729209 posted

    As is the case with all class types, the type information for a static class is loaded by the .NET Framework common language runtime (CLR) when the program that references the class is loaded. The program cannot specify exactly when the class is loaded. However, it is guaranteed to be loaded and to have its fields initialized and its static constructor called before the class is referenced for the first time in your program. A static constructor is only called one time, and a static class remains in memory for the lifetime of the application domain in which your program resides. 

    Shared from the below link

    http://msdn.microsoft.com/en-us/library/vstudio/79b3xss3(v=vs.100).aspx


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 28, 2013 9:20 PM