0

有人可以向我解释使用方括号 [ ] 之间的区别:

Private Function FindItem([ListView] As [ListView], [ColumnIndex] As [Int32], [SearchString] As [String], Optional [IgnoreCase] As [Boolean] = False) As Boolean

...还有这个:

Private Function FindItem(ListView As ListView, ColumnIndex As Integer, SearchString As String, Optional ByVal IgnoreCase As Boolean = False) As Boolean

两者都使用相同的传递参数。

我在哪里可以了解这个奇怪的 vb.net 运算符?

4

2 回答 2

3

在您的示例中,没有区别。括号用于允许使用保留字。

例子 :

Dim [String] As String = Nothing
[String] = "My String has a poor name"

名称周围的 [] 允许您使用保留字。

于 2013-07-02T04:56:27.060 回答
2

关键字作为变量。文档

我不相信使用它们,只需将变量命名为有意义的名称。

Dim _name As String ' better choice - has meaning now.
于 2013-07-02T04:57:39.547 回答