这两个函数都是通过Boolean表达式获取值的方法。
应用方法如下:
var
Form1: TForm1;
implementation
uses
Math, IdGlobal;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
iReturn: Integer;
begin
iReturn := IfThen(100>10, 100, 0);
ShowMessage(IntToStr(iReturn));
iReturn := iif(100<10, 100, 0);
ShowMessage(IntToStr(iReturn));
end;
显示的结果:
100
0
效果一样的,只不过要注意:ifthen是在Math单元中,而iif在IdGlobal单元中。