System.Collections.Tests.Helpers.PerformActionOnAllArrayListWrappers C# (CSharp) Method

PerformActionOnAllArrayListWrappers() public static method

public static PerformActionOnAllArrayListWrappers ( ArrayList arrList, Action action ) : void
arrList ArrayList
action Action
return void
        public static void PerformActionOnAllArrayListWrappers(ArrayList arrList, Action<ArrayList> action)
        {
            // Adapter, GetRange, Synchronized, ReadOnly returns a slightly different version of ArrayList.
            // The following variable contains each one of these types of array lists
            ArrayList[] arrayListTypes =
            {
                (ArrayList)arrList.Clone(),
                (ArrayList)arrList.GetRange(0, arrList.Count).Clone(),
                (ArrayList)ArrayList.Adapter(arrList).Clone(),
                (ArrayList)ArrayList.FixedSize(arrList).Clone(),
                (ArrayList)ArrayList.ReadOnly(arrList).Clone(),
                (ArrayList)ArrayList.Synchronized(arrList).Clone()
            };  

            foreach (ArrayList arrListType in arrayListTypes)
            {
                action(arrListType);
            }
        }