var v:variant; begin v:=vararraycreate([0,n],varstring);//n是上界值 v[0]:=' '; //以次类推 end;
var IntSet:TIntegerSet; //这里定义了一个集合IntSet,但内容是随即的,既有可能内容是{1,2,4,6,9},也有可能是{2,5,7,10,3},但很少会为空 begin Include(IntSet,1); //将1包含进集合IntSet中,这个操作完成以后,集合只有一个元素1 end;
var CharSet:TSysCharSet; //道理同上 begin Include(IntSet,Chr(97)); //将字符'a'包含进集合CharSet中,这个操作完成以后,集合只有一个元素'a' end;
只有整数才能用于集合,别的都不可以. 添加元素用 var s:set of Integer; x:Integer; begin s:=[1,2,3]; s:=s+[4,5]; x:=10; s:=s+[x]; // 单个元素加上方括号就可以了,算是并集运算.
HOHO,只有整数才可以用于集合,那偶问你System单元定义的TSysCharSet是啥类型呢?
HOHO,只有整数才可以用于集合,那偶问你System单元定义的TSysCharSet是啥类型呢?
A set is a collection of values of the same ordinal type. The values have no inherent order, nor is it meaningful for a value to be included twice in a set.The range of a set type is the power set of a specific ordinal type, called the base type; that is, the possible values of the set type are all the subsets of the base type, including the empty set. The base type can have no more than 256 possible values, and their ordinalities must fall between 0 and 255. Any construction of the formset of baseTypewhere baseType is an appropriate ordinal type, identifies a set type.Because of the size limitations for base types, set types are usually defined with subranges. For example, the declarationstype 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 withtype 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 includeset 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 [].
v:variant;
begin
v:=vararraycreate([0,n],varstring);//n是上界值
v[0]:=' ';
//以次类推
end;
IntSet:TIntegerSet; //这里定义了一个集合IntSet,但内容是随即的,既有可能内容是{1,2,4,6,9},也有可能是{2,5,7,10,3},但很少会为空
begin
Include(IntSet,1); //将1包含进集合IntSet中,这个操作完成以后,集合只有一个元素1
end;
我不要整数型的集合,我要字符串呀!
CharSet:TSysCharSet; //道理同上
begin
Include(IntSet,Chr(97)); //将字符'a'包含进集合CharSet中,这个操作完成以后,集合只有一个元素'a'
end;
添加元素用
var
s:set of Integer;
x:Integer;
begin
s:=[1,2,3];
s:=s+[4,5];
x:=10;
s:=s+[x]; // 单个元素加上方括号就可以了,算是并集运算.
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 withtype 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 includeset 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 [].
因此,对于一个特定的集合类型 元素 的总数 必须事先确定Delphi 何时扩充了集合 的定义 ????(我指的是 SET)
SysUtilstype TSysCharSet = set of Char;其实是 Char Set,而 string 是不可以作为 set 集合元素的
本人的习惯说法给大家带来误解了,道歉先.
都不行,你们的建议对单个字符行,也就是:['a','b','z',....]
但对:['aaa','bbb','ccc',....]不行
stringlist?
Tcollection?
select * from table where name in ['aaa','bbb','ccc']
就算Delphi 有这个字符串集合,也不能就直接用啊
select * from table where copy(name,1,1)='m'
为什么?
这种都出错,这种select有什么用?