delphi中字符串拼接_Delphi中的字符串类型(Delphi适用于初学者)

delphi中字符串拼接

As with any programming language, in Delphi, variables are placeholders used to store values; they have names and data types. The data type of a variable determines how the bits representing those values are stored in the computer's memory.

与任何编程语言一样,在Delphi中 ,变量是用于存储值的占位符; 它们具有名称和数据类型。 变量的数据类型决定了代表这些值的位如何存储在计算机的内存中。

When we have a variable that will contain some array of characters, we can declare it to be of typeString. Delphi provides a healthy assortment of string operators, functions and procedures. Before assigning a String data type to a variable, we need to thoroughly understand Delphi's four string types.

当我们有一个将包含一些字符数组的变量时,我们可以将其声明为String类型。 Delphi提供了健康的字符串运算符,函数和过程。 在将String数据类型分配给变量之前,我们需要彻底了解Delphi的四种字符串类型。

短弦 ( Short String )

Simply put, Short String is a counted array of (ANSII) characters, with up to 255 characters in the string. The first byte of this array stores the length of the string. Since this was the main string type in Delphi 1 (16 bit Delphi), the only reason to use Short String is for backward compatibility. To create a ShortString type variable we use: 

简而言之, 短字符串是(ANSII)字符的计数数组,字符串中最多包含255个字符。 该数组的第一个字节存储字符串的长度。 由于这是Delphi 1(16位Delphi)中的主要字符串类型,因此使用短字符串的唯一原因是为了向后兼容。 要创建ShortString类型的变量,我们使用:


var s: ShortString;
s := 'Delphi Programming';​
//S_Length := Ord(s[0]));
//which is the same as Length(s)

The s variable is a Short string variable capable of holding up to 256 characters, its memory is a statically allocated 256 bytes. Since this is usually wasteful - unlikely will your short string spread to the maximum length - second approach to using Short Strings is using subtypes of ShortString, whose maximum length is anywhere from 0 to 255. 

s变量是一个短字符串变量,最多可容纳256个字符,其内存是静态分配的256个字节。 由于这通常很浪费-短字符串不太可能扩展到最大长度-使用短字符串的第二种方法是使用ShortString的子类型,其最大长度在0到255之间。


var ssmall: String[50];
ssmall := 'Short string, up to 50 characters';

This creates a variable called 

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值