In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly shows you the "sample analysis of the beginning and end of the VB.NET lifetime", which is easy to understand and well-organized. I hope it can help you solve your doubts. Let the editor lead you to study and study the "sample analysis of the beginning and end of the VB.NET lifetime".
The "lifetime" of a declared element is the period of time during which the element is available. Variables are elements that have a lifetime. Therefore, the compiler treats procedure parameters and function return values as special cases of variables. The lifetime of a variable represents the period of time for which it can store values. The value of a variable can be changed during its lifetime, but the variable always stores some value.
Different VB.NET lifetimes
The lifetime of a member variable (at the module level and declared outside any procedure) is generally the same as the lifetime of the element that declares the variable. A non-shared variable declared in a class or structure exists as a separate copy of each instance of the class or structure that declares the variable. The lifetime of each such variable is the same as that of its instance. However, the Shared variable has only one lifetime, that is, the full duration of the application running.
"Local variables" (declared within the procedure) exist only during the run-time of the process in which the variable is declared. The same applies to the parameters of the procedure and the return value of any function. However, if the procedure calls other procedures, the local variables retain their values while the called procedure is running.
The beginning of the VB.NET lifetime
When control enters the process of declaring local variables, the lifetime of local variables begins. As soon as the procedure starts running, each local variable is initialized to the default value of its data type. When a procedure encounters a Dim statement (Visual Basic) that specifies initial values, it sets those variables to those values, even if the code has assigned them other values.
Each member of a structure variable is initialized as a separate variable. Similarly, each element of the array variable is initialized separately.
Variables declared in blocks within the procedure, such as For loops, are initialized when entering the procedure. These initializations take effect regardless of whether the code executes the block or not.
The end of the VB.NET lifetime
When the procedure terminates, the values of its local variables are not retained, and Visual Basic reclaims the memory they occupy. The next time the procedure is called, all of its local variables will be created and reinitialized again.
When an instance of a class or structure terminates, its unshared variables lose their memory and values. Each new instance of a class or structure creates and initializes its unshared variables. However, the Shared variable is retained until the application stops running.
Extension of VB.NET lifetime
If you declare a local variable with the Static (Visual Basic) keyword, the lifetime of the variable is longer than the execution time of its procedure. The following table shows how the procedure declaration determines how long the Static variable exists.
The above is all the contents of the article "sample Analysis of the beginning and end of VB.NET Lifetime". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.