Microsoft
Software
Hardware
Network
Question : Linq Distinct
I am having some trouble with Linq on a Distinct. I have a list of custom objects as defined below, and I need to get a list of the distinct entries values. How do I get it to work? I think I just need how to implement the Distinct(comparer).
internal class FirstXTimeDoc : IEqualityComparer
meDoc>
{
public string Article;
public DateTime ArticleDate;
#region IEqualityComparer
meDoc> Members
bool IEqualityComparer
meDoc>.Equ
als(FirstX
TimeDoc x, FirstXTimeDoc y)
{
return (x.Article == y.Article && x.ArticleDate == y.ArticleDate);
}
int IEqualityComparer
meDoc>.Get
HashCode(F
irstXTimeD
oc obj)
{
throw new NotImplementedException();
}
Answer : Linq Distinct
this should work
1:
IEnumerable
distinctNames = yourListOfObjects.Select(x => x.Name).Distinct();
Open in New Window
Select All
Random Solutions
VBA using Search Worksheet Function to Find Question Marks (Tilde)
How do I know what version IIS and IIS management console am I using it.
batch file to search all drives
IIS 7.0 Worker process crashes due to ODP.NET?
Do I have to select a predefined Identity field when using the SELECT INTO clause in a SQL Server stored procedure ?
User name grayed out in SQL Server 2005 Server Management Studio
cascade combobox in a continuous form, access 2007
interop.microsoft.office.c<wbr />ore.dll.
MBOX TO PST
Format Datagrid