delphi - TStringHelper is not returning the correct results -


i'm using tstringhelper in win32 application, when try access particular char or substring values returned not same if use equivalent old string functions.

{$apptype console}  {$r *.res}  uses   system.sysutils;  var   : integer;   s : string; begin   try     i:=12345678;     writeln(i.tostring().chars[1]);  // returns 2     writeln(i.tostring().substring(1)); //returns 2345678      s:=inttostr(i);     writeln(s[1]); //returns 1     writeln(copy(s,1,length(s)));//returns 12345678   except     on e: exception       writeln(e.classname, ': ', e.message);   end;   readln; end. 

the question why tstringhelper functions not equivalent old string functions?

this because methods , properties of system.sysutils.tstringhelper 0 based index, helper compiler {$zerobasedstrings on} directive. can find more info in system.sysutils.tstringhelper documentation.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -