Created
December 7, 2017 11:20
-
-
Save KristofferK/406d5ba91de3efa1f026c8064dd7401e to your computer and use it in GitHub Desktop.
Example usage of .Except in c#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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