C sharp output type question

Q.  Choose the correct one.

int[] numbers = { 9, 4, 1, 3, 8, 6, 7, 2,1 };
  
    var nums = numbers.Take(3);  
  
    foreach (var n in nums)   
    {
  
        Console.WriteLine(n);
  
    }

- Published on 31 Aug 15

a.
7
2
1
b.
9
4
1
c.
3
8
6
d.
1
4
9

ANSWER:
9
4
1
 
Take function takes a number of elements from one collection, and places them in a new collection.
This method is available in the System.Linq namespace that allows you to get the specified number of contiguous elements from the start of a sequence.
In the above code snippet, take function will takes the first three elements from array.
int[] numbers = { 9, 4, 1, 3, 8, 6, 7, 2,1 };

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.)