Vb.Net属性语法 [英] Vb.Net Properties Syntax

查看:53
本文介绍了Vb.Net属性语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我问过工作中的同事,甚至试图在Internet上查找它,但是我没有得到答案.

I have asked my colleagues at work and even tried to look up this on the internet but I haven't been able to get an answer.

两者之间有什么区别

Public Property Name As String

Public Property Name() As String

在属性名称后添加()有什么区别?

What difference makes adding () after the property name?

推荐答案

首先,您可能会发现Property与Methods有很多相似之处.从这个用于参数的Property中的前括号括起来.如果属性没有参数,则可以忽略它.以下是完整的属性声明语法:

First of all you may find it that Property has many similarities to Methods. from this prospective, parenthesis in Property used for parameters. if a Property has no parameter you can omit it. following is the full property declaration syntax:

[Default] [Modifiers] Property PropertyName[(ParameterList)] [As DataType]
[AccessLevel] Get
    ' Statements of the Get procedure.
    ' The following statement returns an expression as the property's value.
    Return Expression
End Get
[AccessLevel] Set[(ByVal NewValue As DataType)]
    ' Statements of the Set procedure.
    ' The following statement assigns newvalue as the property's value.
    LValue = NewValue
End Set
End Property

您可能会在以下链接中找到有价值的提示:vb.net中的参数化属性和功能? https://msdn.microsoft.com/en-us/library/e8ae41a4.aspx

You may find valuable tips in following links: What is the difference between a parameterized property and function in vb.net? AND https://msdn.microsoft.com/en-us/library/e8ae41a4.aspx

这篇关于Vb.Net属性语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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