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
"Service Unavailable" for all ASP pages, but all html pages OK (intermittent)
Decision Matrix
print small fonts (The number must be between 10 and 400...
Passing Paremeters to AddHandler Method in VB.NET
Visual Studio 2008 C# call external program
How to make Report Builder 2.0 install/launch via Clickonce in Report Manager SSRS 2008
.CSV to Database with ODBC connection.
SQL 2008 Database
Unable to Install Microsoft Hotfix KB970895
Open Sharepoint server's pdf file in asp.net...