Good afternoon, how can I check for the presence of a word from an array in a string? eg:

string dwords = "h|w|l|o"; boolean contains = "Hello World".Contains(dwords.split("|")); 

?

  • Cycle, for example? - VladD
  • More options? - Mikhail Ivanov
  • @Hilgert any other options will either explicitly or implicitly use the loop - DreamChild

1 answer 1

Check if character contains string

  string dwords = "h|w|l|o"; var contains = "Hello World".Any(dwords.Contains); 

Check if string contains string from array

 var dwords = new string[] {"Hello","world"}; var contains = "Hello world".Split(' ').Any(dwords.Contains);