All with Function : All « LINQ « VB.Net

Home
VB.Net
1.2D
2.Application
3.Class
4.Data Structure
5.Data Types
6.Database ADO.net
7.Date Time
8.Development
9.Event
10.File Directory
11.Generics
12.GUI
13.Internationalization I18N
14.Language Basics
15.LINQ
16.Network Remote
17.Reflection
18.Security
19.Thread
20.Windows Presentation Foundation
21.Windows System
22.XML
23.XML LINQ
VB.Net » LINQ » AllScreenshots 
All with Function
 

Imports System
Imports System.Linq
Imports System.Collections.Generic


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

Structure Person
    Public LastName As String
    Public Pets() As Pet
End Structure

Public Class Example

    Public Shared Sub Main() 
        Dim people As New List(Of Person)(New Person() _
            {New Person With {.LastName = "A", .Pets = New Pet() {New Pet With {.Name = "A1", .Age = 10}, _
                                                                  New Pet With {.Name = "A2", .Age = 14}, _
                                                                  New Pet With {.Name = "A3", .Age = 6}}}, _
              New Person With {.LastName = "B", .Pets = New Pet() {New Pet With {.Name = "B1", .Age = 1}}}, _
              New Person With {.LastName = "C", .Pets = New Pet() {New Pet With {.Name = "C1", .Age = 8}}}, _
              New Person With {.LastName = "D", .Pets = New Pet() {New Pet With {.Name = "D1", .Age = 2}, _
                                                  New Pet With {.Name = "D2", .Age = 13}}}})
    
        Dim names = From person In people _
                    Where person.Pets.All(Function(petpet.Age > 5_
                    Select person.LastName
    
        For Each name As String In names
            Console.WriteLine(name)
        Next
    
    End Sub
End Class

   
  
Related examples in the same category
1.Using All to return a grouped a list of projectList
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.