Is there any binary-tree data structure in X++. I can see a class for map but cannot find any for binary tree.
Hi Maneesh Kumar,
What stops you to implement your own binary tree ?
There isn't any. The only collection classes available in Dynamics 365 for Operations are Set, Map and Container.
As ievgen suggested, you should implement your own binary tree data structure using BTree and Node class (Typical approach, look It up on google).
yes i am creating my own tree class thanks
Also note that you can use classes defined in .NET. For example, you might be interested in SortedDictionary or SortedSet<T> (included in the base class library).
can we have generics in x++? i have tried to add namespace but angle brackets fail SortedSet<Common> set = new SortedSet<Common>();
It's not officially supported, but there are some fragments of such support. Check my blog post Generic types in X++ (AX 7).
Rather than trying to use it directly from X++, which isn't officially supported, you should consider creating a C# library, handling stuff requiring generics there and exposing a non-generic interface. Then you can add a project reference to an X++ project and call your C# classes from X++.
wow. i never think we can use x++ like this. is it a good practice to create library using c# for production environment since we would need to share dll files?
Oh yes, it's a fully supported feature. But notice that I didn't mention any DLL files; you don't have to deal with them. If you create a project reference inside a solution, it will automatically add an AOT reference (you just have to add it to version control, it doesn't happen automatically) and Visual Studio will build your C# library as well as X++. And the generated assembly (.dll) will be included in deployable packages and deployed to other environments as any other customization.
It's not a completely new approach. In AX 2012, you can add Visual Studio projects to AOT and they're also deployed automatically.
Business Applications communities