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
Setup an event log collector server(Windows Server 2008)
How to delete a replica from the synchronization list?
Access Subdatasheet report II
I have an Excel spreadsheet that is too large
WSUS installation on Sql server
Permissions on sub_folder are incorrectly ordered...
How do I update a powerpoint userform listbox from excel?
How to refresh a Tree View from another Form
activex can't create object solution, ahhh
Return recordset from Oracle via Linked Server and OPENQUERY