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
RDP in Adminpak.msi for Windows Server 2003/XP: How to turn off the connect local resource option
Hide column in CListCtrl
Problems with parsing an error message into a label on a form
Silverlight UserControl with child UserControls
Using a geometry type check constrint in sql sever 2008
Adding new button to windows taskbar
Print raw data to the printer:
Access Runtime Edition - Opens db's in exclusive mode
Add preset percentile counts to SQL SP
How to provide a link in e-mail to open a specific record in Access 2007 ?