type 
  TCharset = set of Char;var
  Charset:TCharset;
  str1,str2: string;
  Achar:char;
begin
  Charset := ['a'..'z'];
  str1 := 'Delphi';
  str2 := Copy(str1,1,1);
  ...
  如何判断从字符串str1中取出的一个字符是否存在于Charset字符集?str2仍然是一个字符串,需要将这个一个字符长的字符串转成Char类型的字符才可以用类似 if Achar in charset then 这样的语句来判断。谢谢!  

解决方案 »

  1.   

    if str2[1] in charset then ....
      

  2.   

    use in str2[1] in charset.
      

  3.   

    if str2[1] in charset then 
      

  4.   

    char表示一个字符,如果用函数pchar表示将sting转换成n个char数组字符.
    用copy(string,1,1)表示取一个字符,但取出来的是string类型
      

  5.   

    不知道Pchar()如何用在以上代码中?
      

  6.   

    这年头看来好象好多人认为char和pchar是一回事。
    哼哼哼
      

  7.   

    A string cannot be convert to a char, but can be convert to a array of char.try to use 
      function StrPCopy(Dest: PChar; const Source: string): PChar;
    uses SysUtils;
    var  A: array[0..79] of Char;
      S: String;
    begin
      S := 'Honk if you know Blaise.';
      StrPCopy(A, S);
      Canvas.TextOut(10, 10, string(A));
    end;