Dynamic Arrays, Growable Arrays होते हैं और Static Arrays पर Advantage रखते हैं। ऐसा इसलिए क्योंकि Array का Size Fixed होता है।
C# में Dynamically Arrays Create करने के लिए, ArrayList Collection का उपयोग करें। यह Object के Ordered Collection को Represent करता है जिसे Individually Index किया जा सकता है। यह Dynamic Memory Allocation, Adding, Searching और Sorting Items in the List की भी अनुमति देता है।
निम्न Example दर्शाता है कि C# में Dynamically Arrays कैसे Create करें।
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