First Last Example : XElement « XML LINQ « VB.Net

Home
VB.Net
1.2D
2.Application
3.Class
4.Data Structure
5.Data Types
6.Database ADO.net
7.Development
8.Event
9.File Directory
10.Generics
11.GUI
12.Language Basics
13.LINQ
14.Network Remote
15.Security
16.Thread
17.Windows Presentation Foundation
18.Windows System
19.XML
20.XML LINQ
VB.Net Tutorial
VB.Net by API
VB.Net » XML LINQ » XElementScreenshots 
First Last Example
  


Imports System.Reflection
Imports System


Public Class Role
    Public ID As Integer
    Public RoleDescription As String
End Class

Public Class Person
    Public ID As Integer
    Public IDRole As Integer
    Public LastName As String
    Public FirstName As String
End Class

Public Class Salary
    Public IDPerson As Integer
    Public Year As Integer
    Public SalaryYear As Double
End Class

Module Module1

    Sub Main()
        Dim people As New List(Of Person)(New Person() { _
            New Person With {.ID = 1, .IDRole = 1, .LastName = "A", .FirstName = "Brad"}, _
            New Person With {.ID = 2, .IDRole = 2, .LastName = "G", .FirstName = "Tom"_
        })

        Dim roles As New List(Of Role)(New Role() { _
            New Role With {.ID = 1, .RoleDescription = "Manager"}, _
            New Role With {.ID = 2, .RoleDescription = "Developer"_
        })


        Dim salaries As New List(Of Salary)(New Salary() { _
                New Salary With {.IDPerson = 1, .Year = 2004, .SalaryYear = 10000.0}, _
                New Salary With {.IDPerson = 1, .Year = 2005, .SalaryYear = 15000.0}, _
                New Salary With {.IDPerson = 2, .Year = 2005, .SalaryYear = 15000.0_
        })

        FirstLastExample()


    End Sub
    Function firstFunc(ByVal n As IntegerAs Boolean
        Return (n Mod 0)
    End Function

    Function lastFunc(ByVal n As IntegerAs Boolean
        Return (n Mod 0)
    End Function


    Public Sub FirstLastExample()
        Dim numbers As Integer() = New Integer() {123456789}
        Dim firstDelegate As New Func(Of Integer, Boolean)(AddressOf firstFunc)
        Dim lastDelegate As New Func(Of Integer, Boolean)(AddressOf lastFunc)

        Dim query = numbers.First()
        Console.WriteLine("The first element in the sequence")

        query = numbers.Last()
        Console.WriteLine("The last element in the sequence")

        Console.WriteLine("The first even element in the sequence")
        query = numbers.First(firstDelegate)

        Console.WriteLine("The last even element in the sequence")
        query = numbers.Last(lastDelegate)

    End Sub

End Module

   
    
  
Related examples in the same category
1.Build an XElement from string
2.Create a single XML element
3.After elements
4.Adding XElement to XElement
5.Before elements
6.Create an in-memory XML document
7.First name element has attributes
8.First name tag has child elements
9.FirstLast Or Default Example
10.FirstName tag's parent has child elements
11.Get first descendant
12.Load the Employees.xml and store the contents into an XElement object.
13.Remove content from XElement
14.Remove from XElement
15.Replace content from XElement
16.Update attribute for XElement
17.Update XElement
18.Using Xml Linq to output Html
19.using XElement.Parse to load Xml from String
20.Xml Literal with string variable
21.Xml literal with function return
22.Enumerate over the array to build an XElement
23.Add 5 new green Fords to the incoming document
24.Add the new node to the bottom of the XML tree
25.Create a query to convert the xml data into fields delimited by quotes and commas.
26.Convert comma separated value to Xml
27.Get child elements by name directly
28.Get value of each color using indexer
29.Is FirstName tag empty?
30.Is idperson tag empty?
31.Remove the 4th Employee element.
32.Using Ling query to create Xml output
33.The Root property returns the top-level XElement
34.Set new value to Xml document
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.