1

I have two lists of strings in a C# program. One is a list of valid strings, the other is a list of directories:

string[] allDirs = Directory.GetDirectories(path);
string[] validEndings = new string[] { "ABC", "DEF" };  // for example

How can I write a Linq statement to get just the string values in allDirs that end with any one of the values in validEndings?

0

1 Answer 1

4
allDirs.Where(d => validEndings.Any(d.EndsWith));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.