C# Lambda function with multiple validations, checking using contains with multiple comparisons

Asked

Viewed 50 times

-1

  • _release is a List with several records
  • x.located is a bool
  • x.Description is a string

I’m trying this way

if (_lancamento.Where(x => x.Localizado && x.descricao.Contains(new List<string> { "6", "9" }))){....}

I do not know if it is possible to do a validation in this way, I tried several ways in lambda and I could not make it work. Obviously the return I want from this if is a True or False

1 answer

1


Cara tries this solution and compares

_lancamento.Where(x => x.Localizado && new List<string> { "6", "9" }.Contains(String.Join("", Regex.Split(x.descricao, @"[^\d]")))
  • It worked right, thanks

Browser other questions tagged

You are not signed in. Login or sign up in order to post.