+92 332 4229 857 99ProjectIdeas@Gmail.com

LINQ Concat() Method (C#.net)



LINQ Concat() Method (C#.net):
The following code shows you how to concatenate two arrays. We can do this using loop and concatenate both array indexes simultaneously. But through LINQ Concat() method we don’t need loop. See the code below.

Code

int[] arr1 = { 2, 1, 2, 3, 7, 5, 10, 9 };
int[] arr2 = { 3, 5, 7, 2, 7, 5, 11, 19 };

var query = arr1.Concat(arr2);

    foreach (var item in query)
       Console.Write(item + " ");


Output of the program is:
2 1 2 3 7 5 10 3 5 7 2 7 5 11 19


0 comments: