What is the use of a shared variable in VB.NET?

It is the same as static in C# and most other languages. It means that every object in the class uses the same copy of the variable, property or method. When used with a method as it is static you don’t need an object instance.

MyClass.DoSomething()

rather than

Dim oObject as New MyClass()
oObject.DoSomething()

Leave a Comment