List<> distinct value
Posted on 2008-06-14
I have an object that I call MyObject. Its parameters are MyObject.Id, MyObject.Name.. etc.
I create a List of this Object.
List<MyObject> myObjectList = new List<MyObject>();
I would like to add to myDistinctList all Objects from myObjectList, except where object exists with the same value in MyObject.Id in myDistinctList.
List<MyObject> myDistinctList = new List<MyObject>();
That is no 2 Objects in myDistinctList may contain the same value in MyObject.Id.
What would be the best way to do this?