Select with Function : Select « 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 Tutorial
VB.Net by API
VB.Net » LINQ » SelectScreenshots 
Select with Function
 

Imports System
Imports System.Linq
Imports System.Collections.Generic
    Structure Pet
        Public Name As String
        Public Age As Integer
    End Structure


Public Class Example

    Public Shared Sub Main() 
        Dim cats() As Pet = {New Pet With {.Name = "A", .Age = 8}, _
                             New Pet With {.Name = "B", .Age = 4}, _
                             New Pet With {.Name = "C", .Age = 1}}

        Dim dogs() As Pet = {New Pet With {.Name = "D", .Age = 3}, _
                             New Pet With {.Name = "E", .Age = 14}, _
                             New Pet With {.Name = "F", .Age = 9}}

        Dim animals() As IEnumerable(Of Pet{cats, dogs}

        Dim query As IEnumerable(Of String(animals.SelectMany(Function(petspets.Select(Function(petpet.Name)))

        For Each name As String In query
            Console.WriteLine(name)
        Next


    End Sub
End Class

   
  
Related examples in the same category
1.Add vbCrLf to the selected value
2.Renaming property in Select
3.Using Select to return a sequence of project names
4.Query Date with Linq
5.Query Reuse with deferred execution
6.Using Concat to create one sequence that contains each array's values
7.Using an indexed SelectMany clause
8.Using Concat to create one sequence
9.Using linq to query the Registry
10.Shows all keys under HKLM\Software that start with the letter C
11.Shows shortcuts to everything under My Recent Documents
12.Counts how many items are in your Favorites folder
13.Uses reflection to show all System assemblies which are currently loaded
14.Projecting Select
15.Using Select to produce a sequence of Integers one value higher
16.Transformation Select
17.Using Select to produce a sequence of strings from a sequence of Integers
18.Anonymous Types in Select Clause
19.Using Select to produce a sequence of each word in an array with new case.
20.Using 'Select New With' to create new objects
21.Using Select to produce a sequence of new objects from two arrays with calculation
22.Using an indexed Select clause to determine if the value of Integers match their position
23.Combine Select and Where to get value from an array based on the value from another array
24.Check for the second letter from each word in an array
25.Use a loop to print out each value in Linq query result
26.num is called the range variable which will take turns representing each value in the array.
w___w___w.___ja___v__a2s._c__o_m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.