Mega Code Archive

 
Categories / VB.Net / Data Structure
 

For Each loops through Array

Imports System Public Class MainClass          Shared Sub Main()      Dim intArray As Integer(  ) = {2, 4, 6, 8, 10}      Dim empArray As Employee(  ) = _        {New Employee(5), New Employee(7), New Employee(9)}      Console.WriteLine("The Integer array...")      Dim theInt As Integer      For Each theInt In intArray          Console.WriteLine(theInt.ToString(  ))      Next theInt      Console.WriteLine("The Employee array...")      Dim e As Employee      For Each e In empArray          Console.WriteLine(e.ToString(  ))      Next e     End Sub End Class  Public Class Employee      Private empID As Integer      'constructor      Public Sub New(ByVal empID As Integer)          Me.empID = empID      End Sub  End Class