Code
class Program
{
static void Main(string[] args)
{
List<int> num1 = new List<int> { 1, 4, 7, 12 };
List<int> num2 = new List<int> { 1, 9, 7, 13, 13,13 };
List<int> concat = num1.Concat(num2).ToList();
List<int> union = num1.Union(num2).ToList();
Console.WriteLine("=======Concat Begins=======");
foreach (int concatnum in concat)
{
Console.WriteLine(concatnum);
}
Console.WriteLine("=======Union Begins=======");
foreach (int unionnum in union)
{
Console.WriteLine(unionnum);
}
}
}
Output
Union gives the distinct values. But Concat gives us all the things between both the list.
By this fact we can say that Concat() is faster than Union() because it doesn't do any processing.
By this fact we can say that Concat() is faster than Union() because it doesn't do any processing.
No comments:
Post a Comment