简体   繁体   English

函数名称周围的方括号

[英]Square brackets around function name

I try to understand delegates at the moment and stumbled across the following snippet: 我试着了解代表,并偶然发现以下片段:

Function [Select](ByVal numbers As List(Of Integer), ByVal filter As Filter) As List(Of Integer)
    Dim result As New List(Of Integer)
    For Each number In numbers
        ' call delegate
        If filter(number) = True Then
            result.Add(number)
        End If
    Next
    Return result
End Function

I searched for an explanation but all I could find is this but that doesn't help me understand the snippet I found. 我搜索了一个解释,但我能找到的只是这个,但这并没有帮助我理解我发现的片段。 Could anyone help me to understand what the square brackets [Select] are for? 谁能帮助我理解方括号[Select]的用途?

They are there because the Select keyword is already used for Select... Case statements. 它们在那里因为Select关键字已用于Select ... Case语句。 Therefore the brackets are used to inform the compiler and IDE that you don't want to use the keyword, you just want it as 'normal' text (whatever that might be in the given context). 因此,括号用于通知编译器和IDE您不想使用关键字,您只需将其作为“普通”文本(无论在给定的上下文中可能是什么)。

FYI, you have to do the same thing in SQL-Server too. 仅供参考,你必须在SQL-Server中做同样的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM