0

Hi can somebody help to get distinct items from Microsoft.Office.Interop.PowerPoint.Hyperlinks using LINQ on the basis of Hyperlink.TextToDisplay and Hyperlink.Address. I want to have items with distinct values for Address and TextToDisplay.

This is what I have tried

Microsoft.Office.Interop.PowerPoint.Hyperlinks links = links.Cast<Microsoft.Office.Interop.PowerPoint.Hyperlink>().Select(p=>p.TextToDisplay).Distinct().ToList();

Thanks in Advance.

user2299182
  • 109
  • 8

1 Answers1

1

Try this:

var distinctLinks = links
    .Cast<Microsoft.Office.Interop.PowerPoint.Hyperlink>()
    .GroupBy(x => new {x.TextToDisplay, x.Address})
    .Select(x => x.First())
    .ToList();
Kaspars Ozols
  • 6,967
  • 1
  • 20
  • 33