Compartir a través de


Struct.newmethod(Object[]) Method

Definition

Creates a struct.

protected:
 void newmethod(cli::array <System::Object ^> ^ varArgs);
[Microsoft.Dynamics.Ax.Xpp.VarArgs]
protected void newmethod (object[] varArgs);
[<Microsoft.Dynamics.Ax.Xpp.VarArgs>]
override this.newmethod : obj[] -> unit
Protected Sub newmethod (varArgs As Object())

Parameters

varArgs
Object[]
Attributes

Remarks

The data type of the item can be specified using the name of a primitive data type or by using the system enum. The items in a struct can be of any of the data types found in the Types system enum, including: string, integer, real, date, container, record, and class. You can create a copy of a struct by using the Struct.definitionString method to create a new struct, as illustrated in the example below. After you have created a struct, you can add new items using the Struct.add method and set the value of items in the struct by using the Struct.value or Struct.valueIndex method.

The following example creates two structs with the same definition and then adds 2 values and an additional item and value to one of them (s1). This struct is then copied to create a new struct by using the Struct.definitionString method.

{ 
    Struct s1, s2, s3; 
    // The two constructors below create the same struct 
    s1 = new Struct(Types::Integer, "age", Types::String, "name"); 
    s2 = new Struct ("int age; str name"); 
    // Print the definitions 
    print s1.definitionString(); 
    print s2.definitionString(); 
    s1.value("age", 25); 
    s1.value("name", "Jane Dow"); 
    // Add a field at runtime 
    s1.add("Shoesize", 45); 
    print s1.definitionString(); 
    print s1.toString(); 
    // Create a container with age, name and shoesize, 
    // using definitionString 
    s3 = new struct(s1.definitionString()); 
    print s3.definitionString(); 
    pause; 
}

Applies to