100 likes | 283 Views
Visual Basic.NET – Collection. Rully Yulian MF MCAD,MCPD,MCT,MVP VB.NET Independent IT Trainer - Application Developer http://www.yulianmf.com rully@yulianmf.com. Overview. Array ArrayList Queue Stack. Array.
E N D
Visual Basic.NET – Collection Rully Yulian MF MCAD,MCPD,MCT,MVP VB.NET Independent IT Trainer - Application Developer http://www.yulianmf.com rully@yulianmf.com
Overview • Array • ArrayList • Queue • Stack
Array • Merupakan struktur data yang menyimpan koleksi data dengan tipe data yang sama • Tiap elemen memiliki nilai indeks • Zero based index untuk lower bound • Array 1D, 2D, multi dimension array • Dim intArr1() As Integer = {} • Dim intArr2() As Integer = New Integer() {} • Dim intArr3() As Integer = {1, 2, 4} • Dim intArr4() As Integer = New Integer() {1, 2, 3} • Dim strArr1(2) As String • Dim strArr2() As String = New String(2) {} • Dim strArr3() As String = New String(2) {"a", "b", "c"} • Redim [Preserver] arrayName (NewUpperBound)
ArrayList • Merupakan object based collection • Terdapat didalam namespace System.Collections • Memiliki sifat Resizable dan Dynamic dalam hal ukuran kapasitas • Memungkinkan terjadinya proses Boxing and Unboxing • Hanya dapat digunakan untuk collection satu dimensi tidak seperti halnya Array. • Dim guitars As New ArrayList() guitars.Add(“PRS") guitars Insert(1, “Washburn") guitars.Remove(“PRS")
Queue • Merupakan Collection of Objects • Terdapat didalam namespace System.Collection namespace • Memiliki sifat FIFO (First In First Out) • Memungkinkan terjadinya proses Boxing and Unboxing • Dim myWishList As New Queue() myWishList.Enqueue(“MPV Car") myWishList.Enqueue(“Mansion") myWishList.Dequeue()
Stack • Merupakan Collection of Objects • Terdapat di dalam namespace System.Collection • Memiliki sifat LIFO (Last In First Out) • Memungkinkan terjadinya proses Boxing and Unboxing • Dim myWishList As New Stack() myWishList.Push(“MPV Car") myWishList.Push(“Mansion") myWishList.Pop()