Except

Coding tip of the day: when you have two lists of strings and want to know the items that are in the first list, but not in the second, use IList.Except:

var firstlist = new List<string>() { "soep", "aap" };

var secondlist = new List<string>() { "soep", "koffie" };

var result = firstlist.Except(secondlist).ToList();

This code returns a list of strings with one item: “aap”

Advertisements

One thought on “Except

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s