Set Operations in D365 F&O - X++ code

Rumman Ansari   Software Engineer   2023-08-29   733 Share
☰ Table of Contents

Table of Content:


Set Operations in D365 F&O - X++ code


Set set1 = new Set (Types::String);

set1.add("D");
set1.add("H");
set1.add("H");
set1.add("F");
set1.add("E");
set1.add("F");

Set set2 = new Set (Types::String);

set2.add("DA");
set2.add("HB");
set2.add("H");
set2.add("F");
set2.add("E");
set2.add("F");

set diffSet1 = Set::difference (set1, set2);
set diffSet2 = Set::difference (set2, set1);
Set unionSet = Set::union (set1, set2);
Set interSet = Set::intersection (set1, set2);

SetEnumerator setEnum = set1.getEnumerator();

while (setEnum.moveNext())
{
   info(strFmt('%1', setEnum.current()));
}