ArrayList

The Arraylist is a collection class that models a dynamic array.whose size increases as required when new objects are added

to the  array.

Namespace                     :   System collections

Implementing interfaces:   Icollection,Ilist,Icloneable,Iconvertible

characteristics            :

  (i)  To store Dynamic data  use the arraylist class .somit compact  memory usage .

  (ii)The search for an item in an arraylist is Performed sequentially.so it is slow.

  (iii) Type of Access is indexed.

 

 example:-

       module module Arraylist

          sub main()

          dim obj as new Arratlist

          obj.Add("one")

          obj.Add("two")

         obj.Add("Three")

          obj.Add("Four")

          obj.Add("five")

  console.writeLine("Number of items in the Arraylist are:"& obj.count)

  dim r as Ienumerator

  e=obj.GetEnumerator

  dim s as string

  Do while e.moveNext

        s=Ctype(e.current,string)

       console.writeLine(s)

 Loop

dim p as string="six"

obj.insert(2,p)

console.writeline("After inserting Number in the Arraylist are:"&obj.count)

dim i as integer

console.writeline("following items are available")

for i=0 to obj.count-1

      console.writeLine(obj.item(i))

next

if obj.cotains(p)Then

     console.writeLine("Record Found!")

 else

       console.writeLine("Record not  Found!")

end if

  end sub

end module

 


Average Rating (0)
by prerit   gamit  in VB.Net  on 3/24/2015 11:27:46 PM  


Post Your Comment
*