Suppose we have two list of numbers and they are:
Now we want to concat this two list of numbers using LINQ. Then our code will be
And the output will be:
3 4 5 6 7 21 3 5 23 4
var numberList1 = new List<int>{3, 4, 5, 6, 7};
var numberList2 = new List<int>{21, 3, 5, 23, 4};
Now we want to concat this two list of numbers using LINQ. Then our code will be
namespace linqTut
{
class Program
{
static void Main(string[] args)
{
var numberList1 = new List<int>{3, 4, 5, 6, 7};
var numberList2 = new List<int>{21, 3, 5, 23, 4};
var resultList = numberList1.Concat(numberList2);
foreach (var i in resultList)
{
Console.Write(i + " ");
}
}
}
}
And the output will be:
3 4 5 6 7 21 3 5 23 4
No comments:
Post a Comment