How would i go about making a function that would return true if a string contains any element of an array?
Something like this:
string str = "hi how are you";
string[] words = {"hi", "hey", "hello"};
would return true.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can do it like this:
This approach does not require that the element be a full word (i.e. the above fragment would return
true, even though the word"fox"is not present there as a single word).