Home  |  Delphi .net Home  |  System.Char  |  IsWhiteSpace Method
IsWhiteSpace  
Method  
Returns true if a given character is a white space character
Char Structure
System NameSpace
CF1.  Function IsWhiteSpace ( UnicodeChar : Char; ) : Boolean;
NotCF2.  Function IsWhiteSpace ( 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 white space character.
 
Examples of white space characters :
 
Chr(9) Tab
Chr(10) Line feed
Chr(13) Carriage return
' ' Blank
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
  myChar : Char;
  myStr  : String;

begin
  myChar := Chr(9);  // Tab character

  if System.Char.IsWhiteSpace(myChar)
  then Console.WriteLine('Tab is a whitespace character')
  else Console.WriteLine('Tab is not a whitespace character');

  myStr := 'Delphi Basics';
  if System.Char.IsWhiteSpace(myStr, 6)  // Note 0 based index
  then Console.WriteLine('''' + myStr[7] + ''' is a whitespace character')
  else Console.WriteLine('''' + myStr[7] + ''' is not a whitespace character');

  if System.Char.IsWhiteSpace(myStr, 7)  // Note 0 based index
  then Console.WriteLine('''' + myStr[8] + ''' is a whitespace character')
  else Console.WriteLine('''' + myStr[8] + ''' is not a whitespace character');

  Console.ReadLine;
end.
Show full unit code
  Tab is a whitespace character
  ' ' is a whitespace character
  'B' is not a whitespace character
 
 
Delphi Programming © Neil Moffatt All rights reserved.  |  Contact the author