ImpicitDataConversion in Ax 2012

Description:-
One very useful feature in AX when dealing with integration between AX and .NET is the way AX implicitly converts the most common data types. For the data types listed in the next table you do not need to convert the data manually. For all other data types, you will have to convert them manually.
.NET Common Language Runtime
X++
System.String
str
System.Int32
int
System.Int64
int64
System.Single
real
System.Double
real
System.Boolean
Boolean
System.DateTime
date
System.Guid
guid
Enums are stored as integers in AX and are treated as integers when they are implicitly converted between .NET and AX.    

We prove this by executing the next example that shows the conversion between System.String and str. The same can be done for any of the other data types in the above table.

static void ImplicitDataConversion(Args _args)
{
    System.String netString;
    str xppString;
    ;   
    // Converting from System.String to str
    netString = "Hello AX!";
    xppString = netString;
    info(xppString);    
    // Converting from str to System.String
    xppString = "Hello .NET!";
    netString = xppString;
    info(netString);
}

X++ is case insensitive, except when dealing with CLR. This means that writing System.string in the previous example will result in     a compile error, whereas writing Str instead of str will not.

Related Posts

Previous
Next Post »

Thanks for comments.....