This method is implemented by using deferred execution. The immediate return value is an object that stores all the information that is required to perform the action. The query represented by this method is not executed until the object is enumerated either by calling its GetEnumerator method directly or by using foreach in Visual C# or For Each in Visual Basic.
The Distinct<TSource>(IEnumerable<TSource>) method returns an unordered sequence that contains no duplicate values. It uses the default equality comparer, Default, to compare values.
In Visual Basic query expression syntax, a Distinct clause translates to an invocation of Distinct<TSource>.
The default equality comparer, Default, is used to compare values of the types that implement the IEquatable<T> generic interface. To compare a custom data type, you need to implement this interface and provide your own GetHashCode and Equals methods for the type.
For an example that uses IEqualityComparer<T>to define a custom comparer, see Distinct<TSource>(IEnumerable<TSource>, IEqualityComparer<TSource>).