Go Dynamics AX and Generic collections of. Net

Source: Internet
Author: User

Transferred from: http://blogs.msdn.com/b/emeadaxsupport/archive/2009/04/23/dynamics-ax-and-generic-collections-of-net.aspx

EmeadaxsupportAPR 9:54 AM
    • 3

I ' m using Dynamics AX want to instantiate the. NET class "System.Collections.Generic.List" in X + +.

Intellisense expands the class to "System.Collections.Generic.List ' 1" However the code cannot is compiled as the class as The classes in the "System.Collections.Generic" namespace is not accepted.

Actually this type as well as every type defined in the namespace System.Collections.Generic is no regular types (is CLA sses) But they is so called "generics". You can see this for example if you were using a Generic in C #, where you had to specify the type of the Generic at Decl Aration/definition (Here for example for string):

System.collections.generic.list<string> List;

More information about. NET generics can is found here:
Generics (C # Programming Guide)

For Dynamics AX 4.0 generics is not supported by the X + + language. This was outlined in the Microsoft Press book "Inside Dynamics AX" on page 111:the following feature of the CLR cannot be used With X + +:

    • Public fields (these can is accessed by using the CLR reflection classes.)
    • Events and Delegates
    • The ref parameter modifier
    • The Out parameter modifier
    • Generics
    • Inner classes
    • The Container composite type
    • The Array composite type
    • Namespace declarations

Besides the "swapping" of the Generic collection into a own Assembly that's referenced back in to Dynamics AX, the only Recommendation is to use the Non-generic counterpart of the collection (see table below).

Generic   non-generic
System.collec tions. Generic   system.collections
collection<t>   ; CollectionBase
comparer<t>   comparer
dictionary<k, v>   Hashtable
list<t>   ArrayList
queue<t>   Queue
sorteddictionary<k, v>   SortedList
stack<t>   Stack
readonlycollection<t>   readonlycollectionbase

The non-generic counterpart of "system.collection.generic.list<t>" would be "System.Collections.Arra Ylist ".

--author: Alexander Lachner
--editor: Alexander Lachner
--date: 23/04/2009
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.