Home  |  Delphi .net Home  |  System.String  |  TrimEnd Method
  
TrimEnd  
Method  
Trims specified characters from the end of a string
String Class
System NameSpace
CF1.  Function TrimEnd ( CharArray : Array of Char ) : String;
CF : Methods with this mark are Compact Framework Compatible
Description
Removes selected trailing characters from the current string.
 
It starts at the end and keeps removing characters when they match one of the CharArray characters. It continues back through the string removing characters until it encounters a character not in the array.
Notes
Like a lot of string methods, the string object itself is not affected - the modified string is returned for assignment.
Microsoft MSDN Links
System
System.String
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

 Buy Proxies at
 Buyproxies.io
 
 
 
A simple example
program Project1;
{$APPTYPE CONSOLE}

var
  strA, strB : String;
  charArray  : Array[0..1] of Char;

begin
  strA := '  --- Hello  --   ';
  charArray[0] := ' ';
  charArray[1] := '-';

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

  strB := strA.TrimEnd(charArray);

  Console.WriteLine('Trimming '' '' and ''-'' chars from the end only');
  Console.WriteLine('strB = ''' + strB + '''');

  Console.ReadLine;
end.
   strA = '  --- Hello  --   '
   Trimming ' ' and '-' chars from the end only
   strB = '  --- Hello'
 
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Contact the author