Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

Searching a string in a string in C#

You can search a string inside a string like below using contains().

  1. using System;
  2. using System.IO;
  3. using System.Text;
  4.  
  5. namespace forgetCode
  6. {
  7. class program1
  8. {
  9. static void Main(string[] args)
  10. {
  11. string firstString = "Forget code";
  12.  
  13. bool bThere = firstString.Contains("get");
  14.  
  15. if (bThere)
  16. {
  17. Console.WriteLine("It is there");
  18. }
  19. else
  20. {
  21. Console.WriteLine("It is not there");
  22. }
  23. }
  24. }
  25. }


Output:
It is there


..