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.
Try this:
var distinctLinks = links
.Cast<Microsoft.Office.Interop.PowerPoint.Hyperlink>()
.GroupBy(x => new {x.TextToDisplay, x.Address})
.Select(x => x.First())
.ToList();