Introducing Radical.sh

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

Checking end of a string in C#

You can check for a string ends with a particular string or not like below:

  1. using System;
  2.  
  3. namespace ConsoleApplication1
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9.  
  10. string name1 = "code";
  11. bool b = name1.EndsWith("de");
  12.  
  13. Console.WriteLine(b);
  14. }
  15.  
  16. }
  17. }


Output:
True

..

  1. using System;
  2.  
  3. namespace ConsoleApplication1
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9.  
  10. string name1 = "code";
  11. bool b = name1.EndsWith("def");
  12.  
  13. Console.WriteLine(b);
  14. }
  15.  
  16. }
  17. }
  18.  


Output:
False

..