比如一个变量,我想判断它是不是在1到70之间,用代码该如何实现?
if VAR1=1..70 then
这样不行啊
你在delphi里面找关于集合的内容
我找到了点,你看看.
Because of the size limitations for base types, set types are usually defined with subranges. For example, the declarations
type
TSomeInts = 1..250;
TIntSet = set of TSomeInts;
create a set type called TIntSet whose values are collections of integers in the range from 1 to 250. You could accomplish the same thing with
type TIntSet = set of 1..250;
Given this declaration, you can create a sets like this:
var Set1, Set2: TIntSet;
...
Set1 := [1, 3, 5, 7, 9];
Set2 := [2, 4, 6, 8, 10]
You can also use the set of ... construction directly in variable declarations:
var MySet: set of 'a'..'z';
...
MySet := ['a','b','c'];
Other examples of set types include
set of Byte
set of (Club, Diamond, Heart, Spade)
set of Char;
The in operator tests set membership:
if 'a' in MySet then ... { do something } ;
Every set type can hold the empty set, denoted by [].