Home  |  Delphi .net Home  |  System.String  |  CopyTo Method
  
CopyTo  
Method  
Copies part of a string into a section of a Char array
String Class
System NameSpace
CF1.  Procedure CopyTo ( SourceStart : Integer; Target : Array of Char; TargetStart : Integer; Count : Integer ) ;
CF : Methods with this mark are Compact Framework Compatible
Description
Copies Count characters from the string object, starting at SourceStart to Target array of characters, from position TargetStart.
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
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

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

var
  source : String;
  target : Array[1..12] of char;
  i      : Integer;

begin
  source := '012345678';

  for i := 1 to 12 do
    target[i] := '-';

  Console.WriteLine('Before CopyTo');
  Console.WriteLine('source = ' + source);
  Console.WriteLine('target = ' + target);

  source.CopyTo(3, target, 5, 4);

  Console.WriteLine('After CopyTo');
  Console.WriteLine('source = ' + source);
  Console.WriteLine('target = ' + target);

  Console.ReadLine;
end.
   Before CopyTo
   source = 0123456789
   target = ------------
   After CopyTo
   source = 0123456789
   target = -----3456---
 
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Contact the author