I have a my collection class of items with fields.
class Item
{
string s1;
string s2;
string s3;
string d1;
string d2;
}
MyCollection looks like that:
public class MyCollection : ICollection<Item>, IEnumerable
{}
I need to distinct that list by 's1', 's2', 's3' but in return get list with all these fields (s1, s2, s3, d1, d2), without duplicated items. So in other words, In return I need a MyCollection<Item>
, not List<anonymousType>
For now I have something like
var list = source.Select(k => new { k.s1, k.s2, k.s2 }).Distinct().ToList();
but it returns a list with only s1,s2,s3 fields.
Is there any way to do it?