将一个数组转化成一个字符串

解决方案 »

  1.   

    看看这个:
    var a:array[0..10] of char;
        b:string;
    begin
      a:='12345';
      b:=a;
      ShowMessage(b);
    end;
      

  2.   

    var
      iArr : Array[1..5] of Integer;
      iIndex : Integer;
    begin
      // 初始化
      for  iIndex := Low(iArr) to High(iArr) do
        iArr[iIndex] := iIndex;
      for iIndex := Low(iArr) to High(iArr) do
        Label1.Caption := Label1.Caption + IntToStr(iArr[iIndex]);
    end;
      

  3.   

    var a:array[0..10] of char;
    b:string;
    begin
    a:='';
    b:='0123456789';
    strPCopy(a,b);
    showMessage(b);
    b :='';
    b := String(a);
    ShowMessage(b);
    end;
      

  4.   

    function ToString(A: array of Byte): string;
    begin
    {  SetLength(Result, Length(A));
      Move(A[0],Result[1],Length(A));}
      //或
      Result:=PChar(@A[0]);
    end;
      

  5.   

    delphi下面字符数组本来就可以直接赋给字符串的。
      

  6.   

    procedure TMainForm.MSComm1Comm(Sender: TObject);
    var
    recstr:array of byte;
    str:string;
    index:integer;
    begin
    if mscomm1.CommEvent=2 then
    begin
    recstr:=mscomm1.Input;
    for index:=low(recstr) to high(recstr) do
    begin
      str:= str+inttohex(recstr[index],2);
    end;
    RealTimeMsg.Text:=RealTimeMsg.Text+'  '+str;
    end;
    end;