随笔 - 2146  文章 - 97 评论 - 11767 trackbacks - 253

procedure TForm1.Button1Click(Sender: TObject);
var
  s1: AnsiString;  //单字节储存
  s2: WideString;  //双字节储存
begin
  s1 := '万一OK';
  s2 := '万一OK';

  ShowMessage(s1[1]);  //显示乱码
  ShowMessage(s2[1]);  //万

  ShowMessage(IntToStr(Length(s1)));  //6
  ShowMessage(IntToStr(Length(s2)));  //4

  ShowMessage(IntToStr(SizeOf(s1)));  //4
  ShowMessage(IntToStr(SizeOf(s2)));  //4, 其 SizeOf 的大小相同,因为它们只是个指针地址
end;

posted on 2007-12-02 12:36  万一  阅读(...)  评论(...编辑  收藏