vb.net - 如何在 VB 10 中编写私有(private)设置自动属性?

标签 vb.net visual-studio-2010 .net-4.0 automatic-properties

在 C# 中:

public string Property { get; private set; }

在 VB 中?

Please vote or/and share your ideas!

最佳答案

像这样:

Private Thingy As Integer
Property Thing() As Integer
    Get
        Return Thingy
    End Get
    Private Set(ByVal value As Integer)
        Thingy = value
    End Set
End Property

VB10 中的汽车属性

Property PartNo As Integer = 44302

但是使用私有(private)集仍然无法在 VB 中完成,甚至在 VB10 中也无法完成,请参见此处:

来自 MSDN(正如约翰所说):

Property Definitions That Require Standard Syntax :

  • Specify different accessibility for the Get and Set procedure. For example, you might want to make the Set procedure Private and the Get procedure Public.

关于vb.net - 如何在 VB 10 中编写私有(private)设置自动属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/968971/

相关文章:

c++ - Visual Studio Dll 和 Matlab

c# - 使用线程时出现内存不足异常

c# - MMC 管理单元和 .Net 4.x

.net - 尝试验证我的组合框时遇到问题

C++ 写入文本文件时出现奇怪的字符

c++ - 使用 Visual Studio 2010 时出现错误/不正确的 C2248 错误

c# - 使用 Entity Framework 和 WCF 的大型应用程序

asp.net - 重新发送 ASP.Net 身份验证 :

vb.net 列表框搜索

c# - SQL Server密码的保存方法