CLRInterop::isInitialized Method [AX 2012]

Determines whether a value has been assigned to the specified CLRObject instance.

client server public static boolean isInitialized(CLRObject clrObject)

Run On

Called

Parameters

clrObject
Type: CLRObject Class
The CLRObject instance to evaluate.

Return Value

Type: boolean
true if a value has been assigned to the CLRObject instance; otherwise, false.

When CLR types are declared in X++, they have a value of nullNothingnullptrunita null reference (Nothing in Visual Basic), regardless of the value of the actual CLR type that is wrapped by the X++ object. The type can be instantiated so that a value can be assigned to it (by using the new method). Or you can use the CLRInterop::null assignment.

Invoking CLR methods on uninitialized CLR types will cause a run-time error.

The following example initializes the CLR object and calls the CLRInterop::isInitialized method to evaluate whether the object was initialized.

static void Job4(Args _args) 
{ 
    System.String s; 
    // This syntax is the same as calling: 
    // ClrObject s = ClrInterop::getObjectForAnyType(“initialized”); 
    System.String s1 = "initialized"; 
  
    // This will print "false". 
    print CLRInterop::isInitialized(s); 
    // This will print "true". 
    print CLRInterop::isInitialized(s1); 
     
    pause; 
}
Show: