Home  |  Delphi .net Home  |  system.String  |  Insert Method
Insert  
Method  
Inserts a string into another string, creating a new, longer string
String Class
system NameSpace
CF1.  Function Insert ( Start:IntegerStart : Integer; Value : String; ) : String;
CF : Methods with this mark are Compact Framework Compatible
Description
A new string is created that contains the source string with Value string inserted at the Start position.
 
Note that the method leaves the original string unchanged.
 
Essentially, the Start value can alternatively be treated as a count of characters before the string is inserted.
Notes
Very Important : Methods in .Net treat strings as starting at 0, unlike traditional Delphi where they started at 1.
Microsoft MSDN Links
system
system.String
 
 
A simple example
program Project1;
{$APPTYPE CONSOLE}

var
  strA, strB, strC : String;

begin
  strA := '123456789';
  strB := '------';

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

  strC := strA.Insert(4, strB);

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

  Console.ReadLine;
end.
Show full unit code
  strA = 123456789
  strB = ------
  strC = 1234------56789
 
 
Delphi Programming © Neil Moffatt All rights reserved.  |  Contact the author