Linq Example 18 - Except

10:50 PM
Linq Query:

//Except
            string[] s1 = { "a", "b", "c", "d", "e", "f" };
            string[] s2 = { "d", "e", "f", "g", "h", "i" };
            

            var s3 = s1.Except(s2);

            foreach (var t in s3)
            {
                Console.WriteLine(t);
            } 


Output:


a
b
c

All the value of s1 except values of s2 which are in s1 will be copied to s3.

0 comments:

Post a Comment