New Dictionary : Dictionary « System.Collections.Generic « VB.Net by API






New Dictionary

  

Imports System.Collections.Generic

Public Structure Employee
   Dim Name As String
   Dim HireDate As Date
   Dim BirthDate As Date
End Structure

Public Module Test
   Public Sub Main()
      Dim employees As New Dictionary(of String, Employee)
      Dim dateToFind As Date
      Dim input As String

      Dim emp As New Employee
      emp.Name = "S"
      emp.HireDate = #1/2/2003#
      emp.BirthDate = #7/12/1977#
      employees.Add(emp.Name, emp)
      emp.Name = "A"
      emp.HireDate = #8/18/1999#
      emp.BirthDate = #3/16/1964#
      employees.Add(emp.Name, emp)
      emp.Name = "B"
      emp.HireDate = #3/1/1987#
      emp.BirthDate = #11/12/1955#
      employees.Add(emp.Name, emp)


      dateToFind = CDate("7/12/1977")
      For Each employee As KeyValuePair(of String, Employee) In employees
         If Month(employee.Value.BirthDate) = Month(dateToFind) AndAlso Day(employee.Value.BirthDate) = Day(dateToFind) Then
            Console.WriteLine("{0:MMMM d} is the bithday of {1}.", dateToFind, employee.Key)
         End If
         
         If Month(employee.Value.HireDate) = Month(dateToFind) AndAlso Day(employee.Value.HireDate) = Day(dateToFind) Then
            Console.WriteLine("{0:MMMM d} is the hiring anniversary of {1}.", dateToFind, employee.Key)
         End If
      Next
   End Sub

End Module

   
    
  








Related examples in the same category

1.Dictionary.Add
2.Dictionary.Item