Quantcast
Viewing all articles
Browse latest Browse all 27016

I'm a little confused about (source - predicate)

This is a MSDN example http://msdn.microsoft.com/en-us/library/bb534972.aspx.

Code:

Structure Pet
        Public Name As String
        Public Age As Integer
        Public Vaccinated As Boolean
    End Structure

    Shared Sub AnyEx3()
        ' Create a list of Pets
        Dim pets As New List(Of Pet)(New Pet() _
                                    {New Pet With {.Name = "Barley", .Age = 8, .Vaccinated = True}, _
                                      New Pet With {.Name = "Boots", .Age = 4, .Vaccinated = False}, _
                                      New Pet With {.Name = "Whiskers", .Age = 1, .Vaccinated = False}})

        ' Determine whether any pets over age 1 are also unvaccinated.
        Dim unvaccinated As Boolean = _
            pets.Any(Function(pet) pet.Age > 1 And pet.Vaccinated = False)

        ' Display the output.
        Dim text As String = IIf(unvaccinated, "are", "are not")
        MsgBox("There " & text & " unvaccinated animals over age 1.")
    End Sub

    ' This code produces the following output:
    '
    ' There are unvaccinated animals over age 1.

In the code, if you take a look at this part, I can not figure out where the keyword Function(...) comes from. It sets a description for the function that follows it, I know this, but in the IDE, Function(pet) is a blue keyword. I'm having trouble finding out how that was put together, or what other descption can go there. At a loss for the terminology also.
Code:

            pets.Any(Function(pet) pet.Age > 1 And pet.Vaccinated = False)

Viewing all articles
Browse latest Browse all 27016

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>