 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to check if a string contains a certain word in C#?
Use the Contains() method to check if a string contains a word or not.
Set the string −
string s = "Together we can do so much!";
Now let’s say you need to find the word “much”
if (s.Contains("much") == true) {    Console.WriteLine("Word found!"); } Let us see the complete code −
Example
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!");       }    } }  Output
Word found!
Advertisements
 