这里的代码是X ++.虽然我熟悉C#,但我对此知之甚少.MS说它在语法上类似于C++和C#.
无论如何,我假设下面的代码是一种方法.它将"Construct"作为关键字.
什么是构造/构造方法?当应用于函数时,construct关键字会发生什么变化?此外,我错误地认为代码会创建某种无限循环?
我的假设是它的返回类型为"InventMovement"的方法.
static InventMovement construct(Common buffer, InventMovSubType subType = InventMovSubType::None, Common childBuffer = null)
{
    InventMovement movement = InventMovement::constructNoThrow(buffer,subType,childBuffer);
    if (!movement)
        throw error("@SYS20765");
    return movement;
}
谢谢!凯文
Construct不是X ++中的关键字,这只是一个construct返回InventMovement类的静态方法.它用于允许您创建基类的派生类,而无需知道要创建哪个派生类.这就是AX实现Factory模式的方式.您将在许多有抽象基类的地方看到AX中使用的这种模式.
InventMovement是许多其他类的抽象基类,例如InventMov_Purch和InventMov_Sales.您不能在抽象类调用new(),所以不是具有开关语句来调用任意new InventMov_Purch()或new InventMov_Sales()每次你需要创建一个时间InventMovement类,您使用InventMovement::construct()的方法来调用正确的新的()为您服务.