1 / 4

טיפול אפשרי להדפסה של 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

aram
Download Presentation

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

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. פונקציית הדפסה שהוגדרה במקור SubPrint(ByVal x AsArrayList) DimiAsInteger Console.WriteLine("Shows Added Items") Fori = 0 Tox.Count() - 1 Console.WriteLine(x(i)) Next EndSub

  3. זהירות – מה יקרה בהדפסה? Structurestum Dim x AsInteger Dim y AsBoolean EndStructure Sub Main() DimItemListAsNewArrayList() 'No datatype OR length! ItemList.Add("Item") ItemList.Add("Another Item") ItemList.Add(3) Dim s Asstum s.x = 8 s.y = True ItemList.Add(s) Print(ItemList) EndSub שימוש בפונקציה Print שראינו קודם להדפסה של הstructure s לא תיתן משהו בעל משמעות לכן לא מומלץ להשתמש ב arrayList לאחסון של מידע מסוגים שונים (אלא אם כן יש צורך מיוחד ונזהרים לטפל במידע באופן נכון)

  4. SubPrintDiffTypes(ByVal x AsArrayList) DimiAsInteger Console.WriteLine("Shows Added Items") Fori = 0 Tox.Count() - 1 Ifx(i).GetType=GetType(String) Or x(i).GetType=GetType(Integer) Then Console.WriteLine(x(i)) ElseIfx(i).GetType = GetType(stum) Then Console.WriteLine(x(i).x & "," & x(i).y) EndIf Next EndSub Structurestum Dim x AsInteger Dim y AsBoolean EndStructure SubMain() DimItemListAsNewArrayList() 'No datatype OR length! ItemList.Add("Item") ItemList.Add("Another Item") ItemList.Add(3) Dim s Asstum s.x = 8 s.y = True ItemList.Add(s) PrintDiffTypes(ItemList) EndSub פתרון אפשרי

More Related