Skip to content

Instantly share code, notes, and snippets.

@KristofferK
Created December 7, 2017 11:20
Show Gist options
  • Save KristofferK/406d5ba91de3efa1f026c8064dd7401e to your computer and use it in GitHub Desktop.
Save KristofferK/406d5ba91de3efa1f026c8064dd7401e to your computer and use it in GitHub Desktop.
Example usage of .Except in c#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DistinctTest
{
class Program
{
static void Main(string[] args)
{
var allIngredients = new string[] { "Kokosmælk", "Karry", "Tomatpuré", "Mælk", "Vand", "Ris", "Salt", "Peber" };
var selectedIngredients = new string[] { "Kokosmælk", "Karry", "Tomatpuré", "Vand", "Ris" };
var notSelectedIngredients = allIngredients.Except(selectedIngredients);
Console.WriteLine(string.Join(", ", notSelectedIngredients)); // Mælk, salt, peber
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment