Articles → CSHARP → Arraylist In C#
Arraylist In C#
What Is An ArrayList?
Syntax
ArrayList obj = new ArrayList();
Namespace
Example
using System;
using System.Collections;
namespace Test1 {
class Program {
static void Main(string[] args) {
ArrayList obj = new ArrayList();
obj.Add("test1");
obj.Add(1);
obj.Add(2.03);
Console.WriteLine("Looping using foreach loop");
foreach(object o in obj) {
Console.WriteLine(o);
}
Console.WriteLine("Looping using for loop");
for (int i = 0; i < obj.Count; i++) {
Console.WriteLine(obj[i]);
}
Console.ReadLine();
}
}
}
Output
Posted By - | Karan Gupta |
|
Posted On - | Wednesday, December 14, 2016 |