Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: VB7
Expertise: beginner
Feb 3, 2003



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Using static variables instead of the Application object

If you want to share a value or an object instance between all the pages of any session, you typically use the Application object. However, a good alternative is to use a public variable defined in a module (VB.NET only), or a static field/property defined in a class. Static properties maintain their values between clients request, and so work like Application variables. They are often a better choice because of their better performace (storing and reading a value can be up to 500 times faster with static variables), since they don't require a lookup in a collection when you refer to them - as it happens for the Application object - and you don't need to cast from Object to a specific type, as you must do with the Application variables (either implicitly or exclicitly, depending on your Option Stric settings), but you store and read a value in a variable or the right type, so no casting and boxing is ever required.
Marco Bellinaso
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date