The C # query expression syntax does not include "excellent". VB, however, for example, from the MSDN docs for the VB Distinct clause :
// VB Dim customerOrders = From cust In customers, ord In orders _ Where cust.CustomerID = ord.CustomerID _ Select cust.CompanyName, ord.OrderDate _ Distinct
The C # equivalent should explicitly call Distinct() in dotted notation.
However, your example may be simplified:
string[] colors = {"red","green","blue","red","green","blue"}; var distinctColors = colors.Distinct(); distinctColors.Dump();
Don't think you need to use query expressions to use LINQ :)
Jon skeet
source share