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

后端 未结 3 1533
一整个雨季
一整个雨季 2020-11-29 09:44

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

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-29 10:24

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

提交回复
热议问题