CSharp examples for System.Collections.Generic:List
adds specified elements at end of the list
using System.Text; using System.Runtime.InteropServices; using System.Linq; using System.Collections.Generic; using System;/*from w w w . j a v a 2 s . c o m*/ public class Main{ /// <summary> /// adds specified elements at end of the list /// </summary> /// <typeparam name="T">type of elements</typeparam> /// <param name="list">list where elements will be added</param> /// <param name="elements">elements to be added to the end of list</param> /// <returns> /// the list that was passed as argument with added elemets if it's not null, /// null if both list and elements where null, /// new list filled with specified elements, if the passed list was null and elements wasn't null /// </returns> public static LinkedList<T> Concat<T>(this LinkedList<T> list, IEnumerable<T> elements) { if (elements == null) { return list; } if (list == null) { return new LinkedList<T>(elements); } foreach (var e in elements) { list.AddLast(e); } return list; } }