טיפול אפשרי להדפסה של ArrayList עם טיפוסים שונים

  • View
    52

  • Download
    0

Embed Size (px)

DESCRIPTION

ArrayList . . Sub Print( ByVal x As ArrayList ) Dim i As Integer Console.WriteLine ( "Shows Added Items" ) For i = 0 To x.Count () - 1 Console.WriteLine (x( i )) Next End Sub. ?. Structure stum - PowerPoint PPT Presentation

Transcript

ArrayList

ArrayList Sub Print(ByVal x As ArrayList) Dim i As Integer Console.WriteLine("Shows Added Items") For i = 0 To x.Count() - 1 Console.WriteLine(x(i)) Next End Sub

? Structure stum Dim x As Integer Dim y As Boolean End Structure Sub Main() Dim ItemList As New ArrayList() 'No datatype OR length! ItemList.Add("Item") ItemList.Add("Another Item") ItemList.Add(3) Dim s As stum s.x = 8 s.y = True ItemList.Add(s) Print(ItemList) End Sub Print structure s arrayList ( ) Sub PrintDiffTypes(ByVal x As ArrayList) Dim i As Integer Console.WriteLine("Shows Added Items") For i = 0 To x.Count() - 1 If x(i).GetType=GetType(String) Or x(i).GetType=GetType(Integer) Then Console.WriteLine(x(i)) ElseIf x(i).GetType = GetType(stum) Then Console.WriteLine(x(i).x & "," & x(i).y) End If Next End Sub Structure stum Dim x As Integer Dim y As Boolean End Structure Sub Main() Dim ItemList As New ArrayList() 'No datatype OR length! ItemList.Add("Item") ItemList.Add("Another Item") ItemList.Add(3) Dim s As stum s.x = 8 s.y = True ItemList.Add(s)PrintDiffTypes(ItemList) End Sub