C sharp output type question

Q.  Choose the correct one.  

int[] A = { 0, 2, 4, 5, 6, 8 };
        int[] B = { 1, 3, 5, 7, 8 };
  
        var nums = A.Union(B);   
   
    foreach (var n in nums)
    {
        Console.Write(n+”  “);
    }

- Published on 31 Aug 15

a. 0 24568 13578
b. 0 2 4 5 6 8 1 3 7
c. 0 1 2 3 4 5 6 7 8
d. None of the above

ANSWER: 0 2 4 5 6 8 1 3 7
 
Union operator returns the union of two sequences. In the above code Union operator returns the sequence of number those are either in array A and B. It removes the duplicate entries.
The Union method will work with two collections of the same type of elements.

Post your comment / Share knowledge


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)