Answers for "c# except"

C#
-1

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
*/
Posted by: Guest on November-21-2020

C# Answers by Framework

Browse Popular Code Answers by Language