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
Trying to connect to windows xp print server using windows 7
"The Directory Service was unable to allocate a relative identifier." when adding machines to AD
explorer view ie8 on windows 7 and wss 3.0
dot replace with "," in VB
Configuring Exchange 2010 (Ports/DNS/Send and Receive Connectors)
Infopath Submit Dataset containing multiple tables to Web Service
In VB.Net how does one call a function name retrieved from a table?
Conditional formatting based on previous record detail
move to a row in listview control - MS Access 2003
Access List Box Form Controls