Delphi中if c then 与if c=true then 的区别?

Delphi中if c then 与if c=true then 的区别?
procedure Tform1.button1click(sender:Tobject);
var t:boolean;
begin
if t then edit1.text :='t=true'
else if not t then edit1.text := 't=false'
else edit1.text := '111';//结果返回TRUE
end;
procedure Tform1.button2click(sender:Tobject);
var t:boolean;
begin
if t=true then edit1.text :='true'
else if t=false then edit1.text := 'false'
else edit1.text := '111';//结果返回111
end;
为什么返回的结果不同?
其他人气:849 ℃时间:2020-04-16 04:47:22
优质解答
在没对t 赋值时,系统默认为true
在button1的if中是判断t是否为真,而button2的if中是判断t是否等于true(是有对t已经赋值了),所以在button2中系统只执行else edit1.text := '111'

希望我的回答对你有帮助,愿早日解开你的疑惑!
我来回答
类似推荐
请使用1024x768 IE6.0或更高版本浏览器浏览本站点,以保证最佳阅读效果。本页提供作业小助手,一起搜作业以及作业好帮手最新版!
版权所有 CopyRight © 2012-2024 作业小助手 All Rights Reserved. 手机版