刪除對象我有這樣的IEnumerable:自IEnumerable
var collection = from obj in list
select new
{
Title = (string)obj.Element("title"),
otherAtt = (string)obj.Element("otherAtt"),
..
..
..
..
};
我想刪除「集合」具有重複名稱的所有對象。並離開最後有一個重複。
例如:
collection = {
{Title="aaa" ,otherAtt="1" ,....},
{Title="bbb" ,otherAtt="2" ,....},
{Title="aaa" ,otherAtt="3" ,....},
{Title="aaa" ,otherAtt="4" ,....},
{Title="ccc" ,otherAtt="5" ,....},
{Title="bbb" ,otherAtt="6" ,....}
}
我需要的過濾器將導致集合看起來像:
collection = {
{Title="aaa" ,otherAtt="4" ,....},
{Title="ccc" ,otherAtt="5" ,....},
{Title="bbb" ,otherAtt="6" ,....}
}
感謝。