Mid From PDF LINQ LINQ

How to perform union of two collections without duplicates?

How to perform union of two collections without duplicates?

var list1 = new[] { "Alice", "Bob", "Charlie" };

var list2 = new[] { "Bob", "David", "Eva" };

var union = list1.Union(list2);

foreach (var name in union)

Console.WriteLine(name);

Explanation:

Union returns distinct elements from both collections.

More from LINQ Tutorial

All questions for this course
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details