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
MS Chart Control Legend Items Truncated
The LinkMasterFields property setting has produced this error: "The object doesn't contain the Automation object 'tbluserSpec. "
How do I reset the path in Windows XP?
ASPX webpage not working with IIS
A non-SYN packet was dropped because it was sent by a source that does not have an established connection with the ISA Server computer.
a generic way to capture the passed in parameter values in a SQL Stored Procedure
creating users in MS Access
Compile Error in Excel
Publishing Site
Multiple users unable to view Datasheet in Sharepoint.