4

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?

Community
  • 1
  • 1
ruedi
  • 5,365
  • 15
  • 52
  • 88
  • 2
    it is how you escape special names in VB. SELECT is keyword (as in `Select Case`) so to use it as a property or function name you escape it with brackets. You can do the same to specify a name you are using which is also a NET Type name such as `Image` or `Version` – Ňɏssa Pøngjǣrdenlarp Jul 04 '14 at 11:19

1 Answers1

5

They are there because the Select keyword is already used for Select... Case statements. 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).

FYI, you have to do the same thing in SQL-Server too.

XN16
  • 5,679
  • 15
  • 48
  • 72