How to deep copy a IList in C# and VB.NET

To deep copy a IList in C# and VB.NET you can use the snippet.

Sample C#

public static IList<T> Clone<T>(IList<T> listToClone) where T : ICloneable
{
	return listToClone.Select(item => (T)item.Clone()).ToList();
}

Sample VB.NET

Public Shared Function Clone(Of T As ICloneable)(listToClone As IList(Of T)) As IList(Of T)
	Return listToClone.[Select](Function(item) DirectCast(item.Clone(), T)).ToList()
End Function

How to check if an array contains a value in Javascript

To check if an array contains a value in Javascript you can use the snippet below.

Sample Javascript

Array.prototype.inArray = function (inputValue) {
	var counter;
	for (counter=0; counter < this.length; counter++) {
		if (this[counter] === inputValue) {
			return true;
		}
	}
	return false;
};

How to join two lists in C# and VB.NET

To join two lists in C# and VB.NET you can use one of the following snippet.

Samples C#

//INIT
var listOne = new List<int>() { 1, 2, 3, 4, 5 };
var listTwo = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

//using Concat, this does not modify listOne. listThree includes all values, even the duplicates.
var listThree = listOne.Concat(listTwo).ToList();

//using Union, this does not modify listOne. listFour includes all values, without duplicates.
var listFour = listOne.Union(listTwo).ToList();

//using AddRange, this modifies listOne. listOne includes all values, even the duplicates.
listOne.AddRange(listTwo);

Samples VB.NET

'INIT
Dim listOne = New List(Of Integer)() From { 1, 2, 3, 4, 5 }
Dim listTwo = New List(Of Integer)() From { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }

'using Concat, this does not modify listOne. listThree includes all values, even the duplicates.
Dim listThree = listOne.Concat(listTwo).ToList()

'using Union, this does not modify listOne. listFour includes all values, without duplicates.
Dim listFour = listOne.Union(listTwo).ToList()

'using AddRange, this modifies listOne. listOne includes all values, even the duplicates.
listOne.AddRange(listTwo)