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
Dead Motherboard, anyway to migrate printers from one XP machine to another
How do I create a relationship in access and specify that referential integrity should NOT be enforced?
Mailbox unavailable. The server response was: 5.7.1 Unable to relay
Client side javascript enabling fields in a listview
How to write a technical user guide for an application
Importing mmf file into Outlook
Date Comparison in MSSQL
Can we enable the guest account on a machine
MS Access 2003 Record Filter Question
Insert values in listbox to access table