gpt4 book ai didi

vb.net - VB.NET 属性中的括号

转载 作者:行者123 更新时间:2023-12-02 17:28:05 25 4
gpt4 key购买 nike

我正在检查工作中的一些遗留代码,我想知道这两个属性之间有什么区别:

公共(public)属性 HasUsedCopies() 作为 bool 值

公共(public)属性 HasUsedCopies 作为 bool 值

使用 VB.NET 到 C# 代码转换器,它们是一样的:

public bool HasUsedCopies { get;放; }

括号是什么意思?

最佳答案

如果您查看 Visual Basic Language Specification under section 9.7 : 属性:

PropertyMemberDeclaration ::=
[ Attributes ] [ PropertyModifier+ ] Property Identifier
[ ( [ ParameterList ] ) ] [ As TypeName ] [ ImplementsClause ]
LineTerminator
[ PropertyAccessorDeclaration+ ]
[ End Property LineTerminator ]
PropertyModifier ::= ProcedureModifier | Default | ReadOnly | WriteOnly
PropertyAccessorDeclaration ::=
PropertyGetDeclaration |
PropertySetDeclaration

在这里您可以看到参数列表和括号中的括起来都是可选的:

[ ( [ ParameterList ] ) ]

所以括号可以省略,因此这两个语句是等价的。

关于vb.net - VB.NET 属性中的括号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36900081/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com