This is a little bit of a weird question, but this has me stumped for some reason. I have the below Extension function which receives 4 string parameters which will contain one of 3 values ("Match", "No Match", "Empty"). Within the function I have an if statement in which I need the condition to contain only the parameters that contain value "Match".
public static void AddIfNotNullAndInAdvancedSearch(
this List<TreeDocument> docs,
TreeDocument value,
string studytitlecontainsshearch,
string outputtitlecontainssearch,
string datasetnamecontainssearch,
string templatenamecontainssearch)
{
if (value.Path != null &&
(studytitlecontainsshearch == "Match" &&
outputtitlecontainssearch == "Match" &&
datasetnamecontainssearch == "Match" &&
templatenamecontainssearch == "Match"))
{
docs.Add(value);
}
}
With my code above, if for example studytitlecontainsshearch is "Empty", then the if statement resolves to false. However, in this scenario I only want to have the remaining 3 parameters in the statement and not ones that contain "Empty" or "No Match". So if only two parameters contain "Match", I want to have only those in the if statement.
I am probably missing a really obvious solution to this so apologies in advance.
Add(value)?