c# - LINQ for removing elements that are started with other element from list -


i have list list<string> paths.

c:\dir\test\ c:\mydir\ c:\yourdir\ c:\dir\ 

i want go through elements (using linq) , remove entries started other element list.

in example c:\dir\test\ starts c:\dir\ - want remove c:\dir\test\.

use list<t>.removeall() method:

sourcelist.removeall(x => sourcelist.any(y => x != y && x.startswith(y))); 

Comments