The message is accurate:
'System.Collections.ArrayList' does not contain a definition for 'Except' and no extension method 'Except' accepting a first argument of type 'System.Collections.ArrayList' could be found (are you missing a using directive or an assembly reference?)
But not that helpful.
Basically, you shouldn't be using ArrayList - it's out of date, and was replaced by the Generic collection types nearly ten years ago!
ArrayLists do not support the IEnumerable<T> interface, which allows them to use Linq extension methods. Replace your ArrayList's with List<string> instead and it should work fine.
-------OFF TOPIC ANSWER SECTION-------
"There is something confusing me in what you wrote in your solution: "ArrayLists do not support the IEnumerable interface, which allows them to use Linq extension methods."
I think it should be: "ArrayLists do not support the IEnumerable interface, which would allow them to use Linq extension methods." or maybe "ArrayLists do not support the IEnumerable interface, which prevents you from using Linq extension methods on them."
Cheers!"
Ah! It's understandable, but...
There are two Interfaces involved here: IEnumerable (the old one, that allows you to use foreach loops) and IEnumerable<T> the newer, strongly typed generic version introduced at .NET V2.0
The former is not the same (and IEnumerable<T> derives from IEnumerable) and only the latter will work with Linq methods, because they are all predicated upon IEnumerable<T> - if you look at the MSDN description for a link method:
http://msdn.microsoft.com/en-us/library/system.linq.enumerable.except(v=vs.110).aspx[
^] it is an IEnumerable<T> method, not IEnumerable.
Try it:
public class enumableObject : IEnumerable
{
public IEnumerator GetEnumerator()
{
throw new NotImplementedException();
}
}
public class enumerableGeneric<T> : IEnumerable<T>
{
public IEnumerator<T> GetEnumerator()
{
throw new NotImplementedException();
}
IEnumerator IEnumerable.GetEnumerator()
{
throw new NotImplementedException();
}
}
Then
List<string> list = new List<string>();
var x = list.Except(list);
Works fine
enumerableGeneric<string> eg = new enumerableGeneric<string>();
var z = eg.Except(eg);
Works fine
enumableObject eo = new enumableObject();
var y = eo.Except(eo);
Gives a compilation error:
MyNamespace.frmMain.enumableObject' does not contain a definition for 'Except' and no extension method 'Except' accepting a first argument of type 'MyNamespace.frmMain.enumableObject' could be found (are you missing a using directive or an assembly reference?)
Exactly the same as a ArrayList.