string contains check c# code example

Example 1: how to cjeck if a string has a word c#

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!");
      }
   }
}

Example 2: c# string contains

var str = "a string to search in";
bool isIn = str.Contains("a string");

Example 3: check if string is in string[] c#

Using System.Linq;


if(stringArray.All(stringToCheck.Contains)){
	//Process
}

Tags:

Lua Example