3

I am getting error in Dynamics Ax 2009 when I try to set a variable of CLR type UInt32 like in the following example:

System.UInt32 duration;
;

duration = 50; 

// Error : Cannot implicitly convert type 'int' to 'System.UInt32'.
// Ax explicit conversion might exist; use System.Convert.

So I tried

duration = (System.Uint32) 50;

// Error: The table is out of range or does not exist.

and finally

duration = System.Convert.ToUInt32(20); // Error: Syntax error.

Any solution to assign value to variable duration?

Thanks in advance for help. Kashif.

DAXaholic
  • 33,312
  • 6
  • 76
  • 74
Lets Do Green
  • 127
  • 11

1 Answers1

4

Try

duration = System.Convert::ToUInt32(20);

as ToUInt32 is a static method of System.Convert

Example:

static void TestJob(Args _args)
{
    System.UInt32 duration;
    str tmp;
    ;

    duration = System.Convert::ToUInt32(20);
    tmp = duration.ToString();
    info(strfmt("%1", tmp));
}
DAXaholic
  • 33,312
  • 6
  • 76
  • 74