Convert datatypes with .NET

One of the things i miss in Dynamics NAV is the possibility for direct evaluate or conversion from one datatype to another.
In C/AL we have to declare a variable and use the EVALUATE function to convert.
This gives us one more variable, and one more line of code.

This can be solved using System.Convert class in the mscorlib assembly.
Simply create the variable shown below, and you can convert to and from all possible combinations.

2017-05-16_0741

Lets se an example: (use the symbol menu to se all the functions)

//Without .NET
EVALUATE(DecimalVariable, '123,50');
Item."Unit Price" := DecimalVariable;

//With .NET
Item."Unit Price" := Convert.ToDecimal('123,50');

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s