I am working on an application where I need to filter a specific value but the reason I have only one parameter to filter it out.
string[] makes = { "UnitMakes:0:Enabled", "UnitMakes:0:UnitMake", "UnitMakes:0:Identity" };
var tt = makes.Where(x => x.Contains("UnitMake")).ToList();
Here tt returns a count of three but I need only the record "UnitMakes:0:UnitMake". I can't add a where clause on a specific record that is because 0 is an index value that starts from 0 to any number. For example
UnitMakes:0:UnitMake
UnitMakes:0:Enabled
UnitMakes:0:Identity
UnitMakes:1:UnitMake
UnitMakes:1:Enabled
UnitMakes:1:Identity
UnitMakes:2:UnitMake
UnitMakes:2:Enabled
UnitMakes:2:Identity
I just want to return the UnitMake values not others.
Based on provided information you can do either:
.Where(x => x.EndsWith("UnitMake"))
or
.Where(x => x.Contains(":UnitMake"))