>>// don't do this at home >> >>public static void AddCollection<T>(this List<T> list, IEnumerable<T> items) >> { >> >> if (items.Count() <= Tuning.AddRangeMinimumItems) // 128 >> { >> foreach (T item in items) >> list.Add(item); >> } >> else >> { >> list.AddRange(items); >> } >> } >>>>
> public static void AddCollection<T>(this List<T> list, IEnumerable<T> items) > { > list.Concat( items ); > } >>
> static void UseConcat() > { > int[] buf = new int[Size]; > List<int> list = new List<int>(); > for (int i = nTimes; --i != 0; ) > { > list.AddCollection(buf); > list.Clear(); > } > > } >>Cetin
Return Value Type: System.Collections.Generic..::.IEnumerable <(Of <(TSource>)>) An IEnumerable<(Of <(T>)>) that contains the concatenated elements of the two input sequences. This method is implemented by using deferred execution. The immediate return value is an object that stores all the information that is required to perform the action. The query represented by this method is not executed until the object is enumerated either by calling its GetEnumerator method directly or by using foreach in Visual C# or For Each in Visual Basic.It's easily seen in the debugger
int[] pp = new int[Size]; List<int> list = new List<int>(); var tt = list.Concat(pp);
i 0 int + pp {int[256]} int[] + list Count = 0 System.Collections.Generic.List<int> - tt {System.Linq.Enumerable.ConcatIterator<int>} System.Collections.Generic.IEnumerable<int> {System.Linq.Enumerable.ConcatIterator<int>} first null System.Collections.Generic.IEnumerable<int> second null System.Collections.Generic.IEnumerable<int> + Non-Public members + Results View Expanding the Results View will enumerate the IEnumerableIt's the about the same as my Queue.Reverse() - remember ?