ArrayList in asp net
C# - ArrayList ClassAdvertisements Previous Page Next Page It represents an ordered collection of an object that can be indexed individually. It is basically an alternative to an array. However, unlike array you can add and remove items from a list at a specified position using an index and the array resizes itself automatically. It also allows dynamic memory allocation, adding, searching and sorting items in the list. Show Methods and Properties of ArrayList ClassThe following table lists some of the commonly used properties of the ArrayList class
The following table lists some of the commonly used methods of the ArrayList class
ExampleThe following example demonstrates the concept Live Demo using System;
using System.Collections;
namespace CollectionApplication {
class Program {
static void Main(string[] args) {
ArrayList al = new ArrayList();
Console.WriteLine("Adding some numbers:");
al.Add(45);
al.Add(78);
al.Add(33);
al.Add(56);
al.Add(12);
al.Add(23);
al.Add(9);
Console.WriteLine("Capacity: {0} ", al.Capacity);
Console.WriteLine("Count: {0}", al.Count);
Console.Write("Content: ");
foreach (int i in al) {
Console.Write(i + " ");
}
Console.WriteLine();
Console.Write("Sorted Content: ");
al.Sort();
foreach (int i in al) {
Console.Write(i + " ");
}
Console.WriteLine();
Console.ReadKey();
}
}
}
When the above code is compiled and executed, it produces the following result Adding some numbers: Capacity: 8 Count: 7 Content: 45 78 33 56 12 23 9 Content: 9 12 23 33 45 56 78csharp_collections.htm Useful Video CoursesVideo 2D Games Development using Unity and C#119 Lectures 23.5 hours Raja Biswas More Detail Video C# Console and Windows Forms Development with LINQ & ADO.NET37 Lectures 13 hours Trevoir Williams More Detail Video Fixing Common Errors in Unity C#16 Lectures 1 hours Peter Jepson More Detail Video ASP.NET CORE and C# REST API With Real World Projects159 Lectures 21.5 hours Ebenezer Ogbu More Detail Video AutoCAD Programming Using C#.NET - Beginner Course193 Lectures 17 hours Arnold Higuit More Detail Video The Beginner's Guide to C#24 Lectures 2.5 hours Eric Frick More Detail Previous Page Print Page Next Page Advertisements |