Home  |  Delphi .net Home  |  System.Char  |  IsPunctuation Method
IsPunctuation  
Method  
Returns true if a given character is a punctuation character
Char Structure
System NameSpace
CF1.  Function IsPunctuation ( UnicodeChar : Char; ) : Boolean;
NotCF2.  Function IsPunctuation ( CharString:StringCharString : String; Index : Integer; ) : Boolean; Static;
CF : Methods with this mark are Compact Framework Compatible
Description
Returns true if the Unicode character, or the character at Index position in CharString is a punctuation character.
 
Examples of punctuation characters :
 
Single quote
Double quote
Comma
Notes
Very Important : Methods in .Net treat strings as starting at 0, unlike traditional Delphi where they started at 1.

Static methods are not methods of an object - they are simply class functions or procedures available at any time.
Microsoft MSDN Links
System
System.Char
 
 
An example of both syntaxes
program Project1;
{$APPTYPE CONSOLE}

var
  myStr  : String;
  i      : Integer;

begin
  if System.Char.IsPunctuation('"')
  then Console.WriteLine('''"'' is a punctuation character')
  else Console.WriteLine('''"'' is not a punctuation character');

  myStr := 'Hello, Neil.';

  for i := 0 to Length(myStr)-1 do
    if System.Char.IsPunctuation(myStr, i)  // Note 0 based index
    then Console.WriteLine('''' + myStr[i+1] + ''' is a punctuation character')
    else Console.WriteLine('''' + myStr[i+1] + ''' is not a punctuation character');

  Console.ReadLine;
end.
Show full unit code
  '"' is a punctuation character
  'H' is not a punctuation character
  'e' is not a punctuation character
  'l' is not a punctuation character
  'l' is not a punctuation character
  'o' is not a punctuation character
  ',' is a punctuation character
  ' ' is not a punctuation character
  'N' is not a punctuation character
  'e' is not a punctuation character
  'i' is not a punctuation character
  'l' is not a punctuation character
  '.' is a punctuation character
 
 
Delphi Programming © Neil Moffatt All rights reserved.  |  Contact the author