- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
How to create arrays dynamically in C#?
Dynamic arrays are growable arrays and have an advantage over static arrays. This is because the size of an array is fixed.
To create arrays dynamically in C#, use the ArrayList collection. It represents ordered collection of an object that can be indexed individually. It also allows dynamic memory allocation, adding, searching and sorting items in the list.
The following is an example showing how to create arrays in dynamically in C#.
Example
using System; using System.Collections; namespace CollectionApplication { class Program { static void Main(string[] args) { ArrayList al = new ArrayList(); al.Add(99); al.Add(47); al.Add(64); Console.WriteLine("Count: {0}", al.Count); Console.Write("List: "); foreach (int i in al) { Console.Write(i + " "); } Console.WriteLine(); Console.ReadKey(); } } }
Output
Count: 3 List: 99 47 64
- Related Articles
- How to dynamically combine all provided arrays using JavaScript?
- How to create div dynamically using jQuery?
- How to create and store property file dynamically in Java?
- How to create arrays in JavaScript?
- MySQL query to create table dynamically?
- How to dynamically create radio buttons using an array in JavaScript?
- How to dynamically allocate a 2D array in C?
- How to fetch a property value dynamically in C#?
- How to create three-dimensional arrays of different sizes in R?
- How to compare two arrays in C#?
- How to initialize jagged arrays in C#?
- How to concatenate Two Arrays in C#?
- How to define jagged arrays in C#?
- How to define param arrays in C#?
- How to merge to arrays in C language?

Advertisements