public static void PerformActionOnAllSortedListWrappers(SortedList sortedList, Action<SortedList> action) { // Synchronized returns a slightly different version of Stack SortedList[] sortedListTypes = { (SortedList)sortedList.Clone(), SortedList.Synchronized(sortedList) }; foreach (SortedList sortedListType in sortedListTypes) { action(sortedListType); } }