Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamic array in C#

Tags:

c#

Is there any method for creating a dynamic array in C#?

like image 652
Siddiqui Avatar asked Feb 27 '09 13:02

Siddiqui


People also ask

What is dynamic array explain it?

In computer science, a dynamic array, growable array, resizable array, dynamic table, mutable array, or array list is a random access, variable-size list data structure that allows elements to be added or removed. It is supplied with standard libraries in many modern mainstream programming languages.

What is dynamic array syntax?

In dynamic arrays, the size is determined during runtime. Dynamic arrays in C++ are declared using the new keyword. We use square brackets to specify the number of items to be stored in the dynamic array. Once done with the array, we can free up the memory using the delete operator.

Can we declare dynamic array in C?

We can create an array of pointers also dynamically using a double pointer. Once we have an array pointers allocated dynamically, we can dynamically allocate memory and for every row like method 2.

What is the use of dynamic arrays?

A dynamic array is an array with a big improvement: automatic resizing. One limitation of arrays is that they're fixed size, meaning you need to specify the number of elements your array will hold ahead of time. A dynamic array expands as you add more elements. So you don't need to determine the size ahead of time.


1 Answers

Take a look at Generic Lists.

like image 162
Chris Van Opstal Avatar answered Sep 17 '22 15:09

Chris Van Opstal