|
Delphi |
|
Set is a collection of value of the same ordinal type, maximal count of item can be no more than 256 items and orinality of any item can be between 0 and 255, so, for instance, you cannot create set of Integer:
var
Chars: set of Char;
DigitChars: set of '0'..'9';
MainModalResultsSet: set of (mrOk,mrCancel);
You can define the set type and use it for defining the set variables:
type
DigitCharsSet: set of '0'..'9';
var
DC1,DC2: DigitCharsSet;
The global set variables can be preinitialized:
var
DigitCharsSet: set of '0'..'9' = ['1','2','3'];
You can use +, −, * and in operators to work with sets:
var
Digits: set of '0'..'9';
...
Digits:=Digits+['4','5'];
if '1' in Digits then // do something
|
|
C# |
|
There is no sets in C#. All we can is to create some own set class for support this functionality or try to simulate sets with enums or bit flags and logical operations.
|
|
|
|
|
|
|