LINQ for removing elements that are started with other element from list
c#, linq
Solution
Use `List<T>.RemoveAll()` method:
sourceList.RemoveAll(x => sourceList.Any(y => x != y && x.StartsWith(y)));
Problem
I have a list `List<string>` with some paths. ``` C:\Dir\Test\ C:\MyDir\ C:\YourDir\ C:\Dir\ ``` I want to go through all the elements (using LINQ) and remove entries that are started with other element from my list. In my example `C:\Dir\Test\` starts with `C:\Dir\` - so I want to remove `C:\Dir\Test\`.