VB.NET中共享变量有什么用? [英] What is the use of a shared variable in VB.NET?

查看:29
本文介绍了VB.NET中共享变量有什么用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

VB.NET 中Shared 变量的用途是什么?

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

推荐答案

它与 C# 和大多数其他语言中的 static 相同.这意味着类中的每个对象都使用变量、属性或方法的相同副本.当与静态方法一起使用时,您不需要对象实例.

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

而不是

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

这篇关于VB.NET中共享变量有什么用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆