加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

如何在Delphi / Pascal中执行多行逐字字符串

发布时间:2020-12-15 09:49:23 所属栏目:大数据 来源:网络整理
导读:在c#中,您可以使用多行文字字符串来创建一个字符串,该字符串跨越源代码中的物理换行符,例如 var someHtml = @"table width="100%" border="0" cellspacing="0" cellpadding="5" align="center" class="txsbody" tbody tr td width="15%" class="ttxb"nbsp;/t
在c#中,您可以使用多行文字字符串来创建一个字符串,该字符串跨越源代码中的物理换行符,例如

var someHtml = @"<table width="100%" border="0" cellspacing="0" cellpadding="5" align="center" class="txsbody">
    <tbody>
        <tr>
            <td width="15%" class="ttxb">&nbsp;</td>
            <td width="85%" class="ttxb"><b>COMPANY NAME</b></td>
        </tr>
    </tbody>
</table>";

但是如何在不使用字符串连接的情况下在delphi中执行此操作,不是为了提高性能,而是为了在视觉上看起来像在c#中一样好而不是

Result :        = '<table width="100%" border="0" cellspacing="0" cellpadding="5" align="center" class="txsbody">';
Result : Result + '<tbody>';

解决方法

How to do this in delphi without using string concatenation?

你不能.不支持多行文字.连接是唯一的选择.

但是,您的Delphi代码在运行时执行串联.在编译时这样做要好得多.所以代替:

Result := 'foo';
Result := Result + 'bar';

Result := 'foo' +
          'bar';

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读