startsWith Summary Checks if the string begins with the specified substring. Usage public bool startsWith(string substr) Returns true if the string begins with the specified substring and false otherwise. Parameters substr The substring to check for at the beginning of the string. Description Checks if the string begins with the specified substring. This method is case-sensitive. Examples Basic Usage 12345import System; string str = "This is a test";Console.log(str.startsWith("This")); // trueConsole.log(str.startsWith("fog")); // false Case-insensitive startsWith 1234567import System; string sentence = "This is a test.";string substr = "this";Console.log( sentence.toLowerCase().startsWith(substr.toLowerCase())); Share HTML | BBCode | Direct Link