C# LINQ — “Distinct”
LINQ (Language-Integrated Query) is a set of integrated C# capabilities which allow queries against data.
Today’s Objective: Use the Distinct LINQ method to create a data value collection of unique elements, and look at a generic C# alternative.
The Distinct Method:
The Distinct method of LINQ allows for the removal of duplicate elements in an array, and returns a new IEnumerable<T> of distinct elements.
The Distinct method is applied to an array via “arrayName.Distinct()”, and returns a new IEnumerable<arrayType> which is the original array, but with all duplicates removed.
The resulting IEnumerable<arrayType> can be used a lot like a variable array, and is able to iterate through all elements in the collection.