Re: How to transform String in Char ???


[ DelphiLand Discussion Forum ]

Posted by webmaster Guido on September 22, 2002 at 04:46:36:

In Reply to: How to transform String in Char ??? posted by Marconi on September 16, 2002 at 18:44:15:

: If I have a String var length = 1, how I can transform it in a Char ???
-------

Let's look at the following example:

var
   S: string;
   C: char;
   i: integer;

" String" is in fact short for "string of characters". Or the reverse, a "char" variable can be seen as a part of a string. To get the char at a certain postion:

  C := S[i]; // gives character at position i

So, if you have a string with a length of just 1 (such as "a" or "b") you can convert as follows to a char:

  C := S[1];


Related Articles and Replies:


[ DelphiLand Discussion Forum ]