Map in D365 F&O - X++ Code to Remove element
X++ Programming Language Map in D365 F&O - X++ Code (Article) Map in D365 F&O - X++ Code (Program)
109
Given Input:
map.insert (1,"Rumman");
map.insert (2,"Osman");
map.insert (3,"Musar");
map.insert (4,"Inzamamul");
map.insert (5,"Hassan");
Expected Output:
Value Hassan for key 5
Value Inzamamul for key 4
Value Osman for key 2
Value Rumman for key 1
Program:
internal final class CodePractice
{
public static void main(Args _args)
{
Map map = new Map (Types::Integer, Types::String);
MapEnumerator mapEnum;
// inserting key and values
map.insert (1,"Rumman");
map.insert (2,"Osman");
map.insert (3,"Musar");
map.insert (4,"Inzamamul");
map.insert (5,"Hassan");
if(map.remove(3))
{
mapEnum = map.getEnumerator();
while (mapEnum.moveNext())
{
info(strFmt("Value %1 for key %2 ", mapEnum.currentValue(),mapEnum.currentKey()));
}
}
}
}
Output:
Value Hassan for key 5
Value Inzamamul for key 4
Value Osman for key 2
Value Rumman for key 1
This Particular section is dedicated to Programs only. If you want learn more about X++ Programming Language. Then you can visit below links to get more depth on this subject.
Value Hassan for key 5 Value Inzamamul for key 4 Value Osman for key 2 Value Rumman for key 1
Program:
internal final class CodePractice { public static void main(Args _args) { Map map = new Map (Types::Integer, Types::String); MapEnumerator mapEnum; // inserting key and values map.insert (1,"Rumman"); map.insert (2,"Osman"); map.insert (3,"Musar"); map.insert (4,"Inzamamul"); map.insert (5,"Hassan"); if(map.remove(3)) { mapEnum = map.getEnumerator(); while (mapEnum.moveNext()) { info(strFmt("Value %1 for key %2 ", mapEnum.currentValue(),mapEnum.currentKey())); } } } }
Output:
Value Hassan for key 5 Value Inzamamul for key 4 Value Osman for key 2 Value Rumman for key 1
This Particular section is dedicated to Programs only. If you want learn more about X++ Programming Language. Then you can visit below links to get more depth on this subject.