c# - Add list of objects to List<List<Objects>> if not contain -
i have list<list<vertex>>
, vertex
has property id
. need add list<vertex>>
list, not duplicate lists.
public void addcomponent(list<vertex> list) { list<list<vertex>> components = new list<list<vertex>>; //i need if (!components.contain(list)) components.add(list); }
you like:
public void addcomponent(list<vertex> list) { var isinlist = components.any(componentlist => { // check equality if (componentlist.count != list.count) return false; (var = 0; < componentlist.count; i++) { if (componentlist[i] != list[i]) return false; } return true; }); if (!isinlist) components.add(list); }