我在ClientDataSet中有一个整数字段,我需要比较一些值,如下所示:
我可以使用const
const
mvValue1 = 1;
mvValue2 = 2;
if ClientDataSet_Field.AsInteger = mvValue1 then
Run Code Online (Sandbox Code Playgroud)
或者枚举
TMyValues = (mvValue1 = 1, mvValue2 = 2);
if ClientDataSet_Field.AsInteger = Integer(mvValue1) then
Run Code Online (Sandbox Code Playgroud)
或类const
TMyValue = class
const
Value1 = 1;
Value2 = 2;
end;
if ClientDataSet_Field.AsInteger = TMyValues.Value1 then
Run Code Online (Sandbox Code Playgroud)
我喜欢类const方法,但似乎不是delphi的方式,所以我想知道你的想法
delphi ×1