The system. Collections namespace contains interfaces and classes that define a set of objects (such as lists, queues, bit arrays, hash tables, and dictionaries.
System. collections. the generic namespace contains interfaces and classes that define a generic set. A generic set allows you to create a strongly typed set. It provides better type security and performance than a non-generic strong set.
The system. Collections. Specialized namespace contains specialized and strong collections, such as list dictionaries for links, bitvectors, and collections that only contain strings.
Arraylist Class: use an array that can be dynamically increased as needed. Using System;
Using System. Collections. Generic;
Using System. text;
Using System. collections;
Namespace Leleapplication1
{
Class Program
{
Static Void Main ( String [] ARGs)
{
Arraylist al = New Arraylist ();
Al. Add ( 100 ); // Single add
Foreach ( Int Number In New Int [ 6 ] {9,3,7,2,4,8} )
{
Al. Add (number );//Add group method 1
}
Int [] Number2 = New Int [ 2 ] {11,12} ;
Al. addrange (number2 ); // Method 2
Al. Remove ( 3 ); // Remove 3
Al. removeat ( 3 ); // Remove 3rd
Arraylist al = New Arraylist (Al. getrange ( 1 , 3 )); // The new arraylist takes only one copy of the old arraylist.
Console. writeline ( " Method 1: " );
Foreach ( Int I In Al) // Do not force conversion
{
Console. writeline (I );//Traversal method 1
}
Console. writeline ( " Method 2: " );
For ( Int I = 0 ; I < Al2.count; I ++ ) // Array is length
{
Int Number = ( Int ) Al 2 [I]; // Mandatory Conversion
Console. writeline (number ); // Method 2
}
}
}
}