I am writing a LINQ query where i want to check if the file name contains one of the following values: ".xls", "xlsx", ".csv"
var results = api.GetAttachments(id).Where(x =>
x.fileName.Contains(".xls") ||
x.fileName.Contains(".xlsx") ||
x.fileName.Contains(".csv"))
.ToList();
I would like to reduce repetition in this linq query and make the file types a variable. So I wrote a list of string variable
List<string> fileTypes = new List<string>(new string[] {".xls", ".xlsx", ".csv" });
How can i incorporate this list of strings in the first query? Basically I want to select objects if the file name is one of the strings mentioned above.
Thanks in advance.