Today, I saw the document prohibiting static variables on the page and the discussion about static variables in ASP. NET in my comments. I don't think it involves the essence of static-What is static.
Static in ASP. NET and C ++ is not much different. In essence, they are all existing address spaces during compilation. In other words, after you build the project, the DLL file of the project already has the space for this static variable (or class, that is to say, after the system loads the DLL during your runtime, the so-called instance of this variable/class already exists and is an applicationProgramPublic, so you can use it directly,At the same time, all pages use the same space..
You need a new instance to use a common class. The reason is that only declarations are not defined in the application. When new is used, a space is allocated to one of its instances in the heap.
In a simple experiment, you can easily understand the differences between them: create a simple project, add a class, add a variable to the class, compile and record the DLL file size; then convert the variable to static (of course, your class must also be static, think about why), compile and record the DLL file size, and compare the two DLL sizes, is it bigger than the previous one? :)