我可以使用字符串“ IsEmpty”吗? Delphi中的方法 [英] Can I use string "IsEmpty" methods in Delphi

查看:251
本文介绍了我可以使用字符串“ IsEmpty”吗? Delphi中的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Embaracdero文档 IsEmpty方法表示字符串类型,我已经在C ++ Builder代码中成功使用了它。

Embaracdero documents "IsEmpty" methods for string types, which I've used successfully with C++ Builder code.

WideString s;

if (s.IsEmpty())
   ....

我在Delphi中尝试过相同的方法,但是无法编译:

I tried the same from Delp and couldn't get it to compile:

var s: WideString;
begin
  if s.IsEmpty then
  ....

我知道您可以将其与空字符串进行比较,或调用Length函数,但是可以从Delphi调用此IsEmpty方法吗?

I know you can compare with an empty string, or call the Length function, but is it possible to call this IsEmpty method from Delphi?

编辑:只是为了澄清一下,这并不是一个String vs Widestring问题。

Just to clarify, this wasn't meant as a String vs Widestring issue.

基本上,我上面链接到的文档描述了Pascal语法以及C ++语法,但这似乎不起作用。我认为这只是文档中的一个缺陷。

Basically, the docs I link to above describe a Pascal syntax, as well as a C++ one, yet this doesn't seem to work. I assume this is just a flaw in the documentation.

如果System :: WideString :: WideString为空,则返回true。

Pascal:函数IsEmpty:bool;

Pascal: function IsEmpty: bool;

推荐答案

字符串不是Delphi中的类,因此它没有方法,您必须使用函数来进行字符串操作,例如,长度,复制等。字符串是C ++中的类,因此您可能对此感到困惑。

String is not a class in Delphi therefore it has no methods, you have to use functions for string manipulations like Length, Copy, etc... String is a class in C++ so maybe you are confused by that.

这篇关于我可以使用字符串“ IsEmpty”吗? Delphi中的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆