What will be output of following function when called?

public string Common()
{
// Assign two arrays.
int[] array1 = { 1, 2, 3 };
int[] array2 = { 2, 3, 4 };

// Call Intersect extension method.
var intersect = array1.Intersect(array2);
// Write intersection to screen.
foreach (int value in intersect)
{
Console.WriteLine(value);
}
}

 Posted by Learningtorise on 12/4/2013 | Category: C# Interview questions | Views: 1522 | Points: 40
Answer:

Output:
2
3

* An intersection is the subset of each collection that is found in both collections. Given two sets of values, It will find our whether there is any common element among two and return them.


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response

More Interview Questions by Learningtorise