Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
对 Visual Basic 来说有点新。
你知道在 C# 中我们会写例如:
public class MyClass { public int Age {get; set;} }
我需要做类似的事情才能使用一个类来捕获一些数据,然后创建一个这个对象类型的列表。但是,我如何在 Visual Basic 中编写一个简单的 Get、Set 类?有什么方法可以像我们在 C# 中那样简单地实现这一点??????谢谢!!
没有花括号,也没有明确的 get;放;
Public Property Age As Integer
见MSDN
只需将其声明为公开:
Public Age As Integer = 0
Private _Age as Integer Public Property Age() As Integer Get Return _Age End Get Set(ByVal value As Integer) _Age = value End Set End Property