Share via


CLRInterop::isInitialized Method

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

Syntax

client server public static boolean isInitialized(CLRObject clrObject)

Run On

Called

Parameters

Return Value

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

Remarks

When CLR types are declared in X++, they have a value of null Nothing nullptr unit a 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.

Examples

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; 
}

See Also

Reference

CLRInterop Class