Removing objects from an array when new items don’t exist.

Hi Folks,

Stupid question o'clock 🙂

I am trying to solve, what I think is a simple problem, but I fear I am over thinking it.

I am reading a bunch of file attributes, and getting some metadata from them. That meta data is then added to an array. What I would like to do is, when adding the metadata to the array, check if the additions and if they don't remove the ones that don't exist from the original array members, but add all the new objects.

I'll try and represent this differently…

I've parsed my first file, and I have an array with :

A, B, C, D, E,F

I am now moving on to my next file, and need to add these :

A, B, C, J, L, M

I would like the resulting array to look like :

A, B , C, J, L, M

But if no entities match, just add them to the array.

What I am trying to achieve is to be left with only the most common entities that are added to the array.

I hope this makes sense…

Cheers

by PST-Hater via /r/csharp

Leave a Reply