Similar to remove duplicate items from list in c#
I want to create a list then if a list item appears more than once, only treat it as one item, not duplicating it in the list and not ignoring it either.
Using the example from the ticket above: https://dotnetfiddle.net/NPqzne
List<MyClass> list = new List<MyClass>();
list.Add(new MyClass() { BillId = "123", classObj = {} });
list.Add(new MyClass() { BillId = "777", classObj = {} });
list.Add(new MyClass() { BillId = "999", classObj = {} });
list.Add(new MyClass() { BillId = "123", classObj = {} });
var result = myClassObject.GroupBy(x => x.BillId)
.Where(x => x.Count() == 1)
.Select(x => x.First());
Console.WriteLine(string.Join(", ", result.Select(x => x.BillId)));
How would I change that so results are
123, 777, 999
rather than ignoring 123
altogether because it's a duplicate?