Remove duplicates within a List, ignore case and whitespace

This is a similar question for this, I don’t know if it will ignore whitespace or ignore case:

To ignore case you can use this:

list.Distinct(
    StringComparer.CurrentCultureIgnoreCase).ToList();

More details about question you can find here:

For whitespace it is more complex since it is not a problem of a distinct function but a form of data so can you clean data before you go into filtering?

2 Likes