Why does Delphi warn when assigning ShortString to string?

后端 未结 6 1614
栀梦
栀梦 2021-01-07 18:42

I\'m converting some legacy code to Delphi 2010.

There are a fair number of old ShortStrings, like string[25]

Why does the assignment below:

         


        
6条回答
  •  鱼传尺愫
    2021-01-07 19:12

    I don't really know Delphi, but if I remember correctly, the Shortstrings are essentially a sequence of characters on the stack, whereas a regular string (AnsiString) is actually a reference to a location on the heap. This may have different implications.

    Here's a good article on the different string types: http://www.codexterity.com/delphistrings.htm

    I think there might also be a difference in terms of encoding but I'm not 100% sure.

提交回复
热议问题