Do Except operation between two string arrays in CSharp

Description

The following code shows how to do Except operation between two string arrays.

Example


     /* w  w w .j a  va2 s . c o  m*/
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;


public class MainClass{

   public static void Main(string[] args){   
         String[] First = { "One", "Two", "Two", "Three", "Four" };
         String[] Second = { "Three", "Four", "Five", "Six" };

         var ShowExcept = First.Except(Second);

         Console.WriteLine("Except:");
         foreach (String ThisElement in ShowExcept)
            Console.WriteLine(ThisElement);

   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    LINQ »




Operator
Select
Where
OrderBy
Group
Join
Let
LINQ