
No such restrictions apply to the ArrayList which can be a collection of data of diverse data type. In contrast, an ArrayList can have any type of items or elements.įurther, an Array can only contain data of the same data type. What that means is an Array can be a collection of only a specific type of elements. For instance, unlike an ArrayList, an Array is a strongly typed language. However, there are certain qualities that are unique to an Array. This is useful in those situations where you are dealing with a list comprising of similar items, which can be anything like a list of cars, food items, or just about anything. Major differences between Array and ArrayListĪn Array is a collection of similar data types that are referred to by a common name. Both are similar in that they act as a placeholder of data that can be referred to by a single name though there are several ways both differ significantly. " & Format(finish.Millisecond, " 000"))Ĭonsole.In this article, we are going to discuss Array and ArrayList, two important data structures in C#. " & ltimer.Millisecond)Ĭonsole.WriteLine( " Finish Time = " & finish.Second & ". Ltime = (finish.Second - ltimer.Second) * 1000 + finish.Millisecond - ltimer.MillisecondĬonsole.WriteLine( " Start Time = " & ltimer.Second & ". " & atimer.Millisecond)Ĭonsole.WriteLine( " Array Time = " & atime.ToString) " & finish.Millisecond)Ĭonsole.WriteLine( " Array List Time = " & altime)Ītime = (finish.Second - atimer.Second) * 1000 + finish.Millisecond - atimer.MillisecondĬonsole.WriteLine( " Start Time = " & atimer.Second & ". " & altimer.Millisecond)Ĭonsole.WriteLine( " Finish Time = " & finish.Second & ". From the Collection of Dictionaries down to this does a LOT.Īltime = (finish.Second - altimer.Second) * 1000 + finish.Millisecond - altimer.MillisecondĬonsole.WriteLine( " Start Time = " & altimer.Second & ".

#Int array vs arraylist summary code
Think for a minute what that is doing, it's iterating through a Collection of Dictionary Collections and getting the appropriate string for each and very very rapidly and efficiently! // Follow the code path through that down to this other one above and you will see what I mean. Take the first one: // var x = listOfLists.Aggregate blah blah. Aggregate here are good examples and it can be many Types. " \n\nWhich is set to the Data file: \n" + " The following currently use this Reports Folder:\n\n" ĭic.Aggregate(text, (current, pair) => current + var i = 0 // var text = "" // foreach (var dic in listOfLists) // \n\n", dir), / /// private static void DisplayResults / & faster because instead of a loop it's a LINQ query! / It directly calls the Mother Method of them all below this one. / ViewAllAssociations() Has it's own special Size & Location Settings. / This one accepts the Collection of Dictionaries for

Here are a couple of prime examples in optimized code form. If you do not exceed the capacity it is going to be as fast as an array.īetter handling and much easier way of doing things.Ĭopy Code // The main thing I can add to this is that a LINQ query is almost always faster than a loop such as a foreach, etc. However because ArrayList uses an Array is faster to search O(1) in it than normal lists O(n). Since the add from ArrayList is O(n) and the add to the Array is O(1). You will only feel this if you add to often. It creates a new Array and copies every element from the old one to the new one. However when you add an element to the ArrayList and it overflows. Where as, the lower bound of an ArrayList is always zero.Īrray is faster and that is because ArrayList uses a fixed amount of array. Where as, ArrayList always has exactly one dimension. Where as, ArrayList is in the System.Collections namespace. Where as, ArrayList can hold item of different types.

Where as, ArrayList can increase and decrease size dynamically.Īn Array is a collection of similar items.
