linq except list code example

Example 1: linq c# object except two lists

var filtered = unfilteredApps.Where(i => !excludedAppIds.Contains(i.Id));

Example 2: c# except

using System;
using System.Linq;

class Program
{
    static void Main()
    {
        // Contains four values.
        int[] values1 = { 1, 2, 3, 4 };

        // Contains three values (1 and 2 also found in values1).
        int[] values2 = { 1, 2, 5 };

        // Remove all values2 from values1.
        var result = values1.Except(values2);

        // Show.
        foreach (var element in result)
        {
            Console.WriteLine(element);
        }
    }
}
/*
result
3
4
*/