Delphi Basics Home  |  Delphi Basics .NET Home  |  System.String  |  StartsWith Method
StartsWith  
Method  
Determines if a string starts with a specified string
String Class
System NameSpace
CF1.  Function StartsWith ( Value : String ) : Boolean;
CF : Methods with this mark are Compact Framework Compatible
Description
Returns true if the start of a string matches the Value specified string.
 
It is case sensitive.
Microsoft MSDN Links
System
System.String
System.String.StartsWith
 
A simple example
program Project1;
{$APPTYPE CONSOLE}

var
  strA : String;

begin
  strA := 'ABCDEF';

  Console.WriteLine('strA = ' + strA);

  if strA.StartsWith('ABC')
  then Console.WriteLine('strA starts with ABC')
  else Console.WriteLine('strA does not start with ABC');

  if strA.StartsWith('abc')
  then Console.WriteLine('strA starts with abc')
  else Console.WriteLine('strA does not start with abc');

  Console.ReadLine;
end.
   strA = ABCDEF
   strA starts with ABC
   strA does not start with abc
 
© CodeGear 2006 - 2007. All rights reserved.