use the StartsWith() and EndsWith() methods to check if a string contains a specified substring at the start and end : String : Data Types C# Source Code


Custom Search

C# Source Code » Data Types » String »

 

use the StartsWith() and EndsWith() methods to check if a string contains a specified substring at the start and end








    
 


using System;

class MainClass {

    public static void Main() {
        string[] myStrings = {"To", "be", "or", "not","to", "be"};
        string myString = String.Join(".", myStrings);        
        Console.WriteLine("myString = " + myString);
        if (myString.StartsWith("To")) {
            Console.WriteLine("myString starts with \"To\"");
        }
        if (myString.EndsWith("be")) {
            Console.WriteLine("myString ends with \"be\"");
        }

    
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Data Types
» String