Vb.net – the use of a shared variable in VB.NET

vb.net

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

Best Answer

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()