- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
ArrayList in C#
A resizable implementation of the List interface is called ArrayList. It is a non-generic type of collection in C# that dynamically resizes.
Let us see how to initialize ArrayList in C# −
ArrayList arr= new ArrayList();
Add an element like the below-given code snippet −
ArrayList arr1 = new ArrayList(); arr1.Add(120); arr1.Add(160);
Let us see the complete example to implement ArrayList in C# −
Example
using System; using System.Collections; public class MyClass { public static void Main() { ArrayList arr1 = new ArrayList(); arr1.Add(120); arr1.Add(160); ArrayList arr2 = new ArrayList(); arr2.Add(200); arr2.Add(240); arr1.AddRange(arr2); for (int i = 0; i < arr1.Count; i++) Console.WriteLine(arr1[i]); } }
Output
120 160 200 240
Advertisements