Size has private access in ArrayList

You are attempting to access a private member of ArrayList, part of its internal working that are not supposed to be used externally If you want to get the size of the arraylist you want the method: Why is it like this This gives the ArrayList class the option to store size in whatever way it wants. Does … Read more

ArrayList vs List<> in C#

Yes, pretty much. List<T> is a generic class. It supports storing values of a specific type without casting to or from object (which would have incurred boxing/unboxing overhead when T is a value type in the ArrayList case). ArrayList simply stores object references. As a generic collection, List<T> implements the generic IEnumerable<T> interface and can be used easily in LINQ (without requiring any Cast or OfType call). ArrayList belongs to the days that C# didn’t have … Read more