Except intersection of two arrays in c#

Hello Devs, this is the task recently I received from one of my colleague.

The Question is below

Two input Arrays

A = { “Blue”, “Green”, “Yellow”, “Red” }
B = { “Green”, “White”, “Red” }

Output should be like, The output collection should be sorted as well.
Output: {“Blue”, “Red”, “Yellow” }

The output is the not the intersection of the two arrays.

The solution is below:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ChenTest
    class Program
        static void Main(string[] args)
            string[] A= new string[] {"Blue","Green","Yellow","Red"};
            string[] B= new string[] {"Blue","Red","Yellow"};
            var result = A.Except(B).Union(B.Except(A));

            foreach (string element in result)



Vijay Bhaskar from Hyderabad. Here in the IT industry for years and during these days I have enjoyed working with Microsoft Technologies such as Office 365, SharePoint 2013/2010, MOSS 2007, Asp.Net, C#.Net and Ajax, jQuery, JSON, ECMA, Angular etc. Currently working for Capgemini and Microsoft certified developer for SharePoint. During this period worked on various concepts like Office Apps, SharePoint Apps ( Provider hosted, SharePoint hosted), Azure, Workflows, Web part development, SSOM, CSOM, JSOM, SPServices, SharePoint Master Pages, SharePoint custom pages, SharePoint on Azure.

Leave a Reply

Your email address will not be published. Required fields are marked *