RSD
RSD

Reputation: 1

Declaration class as array in AX 2012

I wanted to declare a variable like this in AX 2012 : classX[] error = new classX(); in a Class Y

[DataContractAttribute]
public classX
{

}

[DataContractAttribute]
public classY
{
      classX[]  error = new classX();
}

But I can't declare it, is that possible?

I tried it this way but it didn't work: Array error = Array of classX; classX error[] = new classX();

Upvotes: 0

Views: 129

Answers (1)

Alex Kwitny
Alex Kwitny

Reputation: 11544

The proper way to do what you're trying to accomplish is below. Take a look at this link for some more info.

ClassY definition:

[DataContractAttribute]
class ClassYContract
{
    List classXList;
}

[
    DataMemberAttribute,
    AifCollectionTypeAttribute('return', Types::Class, classStr(ClassXContract)),
    AifCollectionTypeAttribute('_classXList', Types::Class, classStr(ClassXContract))
]
public List parmClassXList(List _classXList = classXList)
{
    classXList = _classXList;

    return classXList;
}

ClassX definition:

[DataContractAttribute]
class ClassXContract
{
}

Upvotes: 0

Related Questions