VB.Net/LINQ/Count — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 12:41, 26 мая 2010
Get count from the query
Module Program
Sub Main()
Dim currentVideoGames() As String = {"A", "B", "this is a test", "D", "E", "S"}
Dim numb As Integer = (From g In currentVideoGames _
Where g.Length > 6 _
Order By g _
Select g).Count()
Console.WriteLine("{0} items honor the LINQ query.", numb)
End Sub
End Module
Get the count of all employees hired this year.
Imports System
Imports System.Xml.Linq
Public Class MainClass
Public Shared Sub Main()
Dim employees As XElement = XElement.Load("Employees.xml")
Dim cnt = Aggregate ele In employees.<Employee> _
Where CDate(ele.<HireDate>.Value).Year = Now.Year _
Into Count()
Console.WriteLine("{0} employees were hired this year.", cnt)
End Sub
End Class