using System;
public class Demo {
public static void Main() {
string s = "Together we can do so much!";
if (s.Contains("much") == true) {
Console.WriteLine("Word found!");
} else {
Console.WriteLine("Word not found!");
}
}
}
Using System.Linq;
if(stringArray.All(stringToCheck.Contains)){
//Process
}
string stringToCheck = "text1";
string[] stringArray = { "text1", "testtest", "test1test2", "test2text1" };
foreach (string x in stringArray)
{
if (x == stringToCheck)
{
// Process...
}
}
// This is to check if a string contains only the question mark "?".
string input = "???";
bool isAllQuestion = input.All(c => c=='?');
Console.WriteLine(isAllQuestion);
Console.ReadLine();
// output: True