Delphi ????????????????????? string???AnsiString???WideString???String[n]???ShortString
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Delphi ????????????????????? string???AnsiString???WideString???String[n]???ShortString相关的知识,希望对你有一定的参考价值。
?????????str1 pre begin short ring eof show ?????? str
//???????????? string var str: string; {??????} begin str := ????????????; {??????} ShowMessage(IntToStr(Length(str))); {?????????: 4} end;
//???????????? AnsiString; ???????????????(2007)?????????????????????, String ?????? AnsiString var str: AnsiString; begin str := ????????????; ShowMessage(IntToStr(Length(str))); {?????????: 4} end;
//???????????? WideString (???????????? AnsiString) var str: WideString; begin str := ????????????; ShowMessage(IntToStr(Length(str))); {?????????: 2} end;
//??????????????? var str1: String[6]; {???????????????????????? 255} str2: String[100]; begin {??????????????????????????????} str1 := ????????????; ShowMessage(str1); {??????} ShowMessage(IntToStr(Length(str1))); {4; ????????????????????????} ShowMessage(IntToStr(SizeOf(str1))); {7; ?????????????????????} {?????????????????????} str1 := ???????????? Delphi ?????????; ShowMessage(str1); {?????????} ShowMessage(IntToStr(Length(str1))); {6; ????????????????????????????????????} ShowMessage(IntToStr(SizeOf(str1))); {7; ?????????????????????} {??????: ????????????????????? 6 ???? ?????? SizeOf ??? 7 ? } {??????????????????????????????????????????????????????????????????????????????} {????????????, ????????? str2 ???????????????, ??????????????????(str2[0])????????????????????? ???A???} str2 := ???iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii???; {65???} ShowMessage(str2[0]); {A} ShowMessage(IntToStr(Ord(str2[0]))); {65; ?????? ???A??? ??? ASCII ??????????????????, ???????????????} {?????????????????? Ord(str2[0]) ????????? Length ???????????????????????????? } {??????????????????????????????; ???????????????, ???????????? SetLength ????????????} end;
//ShortString; ???????????? String[255] var str: ShortString; begin str := ???????????? Delphi ?????????; ShowMessage(str); {????????? Delphi ??????} ShowMessage(IntToStr(SizeOf(str))); {256; ????????????} ShowMessage(IntToStr(Length(str))); {18 ; ??????????????????} ShowMessage(IntToStr(Ord(str[0]))); {18 ; ????????????????????????????????????} end;
以上是关于Delphi ????????????????????? string???AnsiString???WideString???String[n]???ShortString的主要内容,如果未能解决你的问题,请参考以下文章