Sprint Debugger
Sprint Debugger

Reputation: 138

Difference (except) between two dimensional array of type <class> and List of type <class>

Lets have a class called "ClassA" and lets have the following code:

...
ClassA[,] all = new ClassA[8,8];
...
//Array "all" is filled with objects
...
List<ClassA> some = new List<ClassA>();
...
//List "some" is filled with some objects taken from all
...
List<ClassA> others = new List<ClassA>();

Now I'd like to get the difference between "all" and "some", for example something like this: other = all - some

Upvotes: 0

Views: 221

Answers (1)

Daniel Hilgarth
Daniel Hilgarth

Reputation: 174329

Generally speaking, you can use Except:

var others = all.Except(some);

In your specific case with the two dimensional array, you first have to bring all into the right "form" using Cast:

var others = all.Cast<ClassA>().Except(some);

Upvotes: 2

Related Questions