Good morning, I have to search through a FOREACH if a field contains any of the strings. Example
foreach (var item in Clientes.Listado)
{
if (item.Nombre.Contains("Juan") || item.Nombre.Contains("Carlos") || item.Nombre.Contains("Pedro"))
{
...Codigo
}
}
I would like to change item.Nombre.Contains("Juan") || item.Nombre.Contains("Carlos") || item.Nombre.Contains("Pedro")
For something more Verbose as in FoxPro that would be
if INLIST(item.Nombre,"Juan","Carlos","Pedro")
You can just put them into an array and test using
.Any()
ifitem.Nombre
it contains at least one of the values in the array.