【问题标题】:Variable is not of the type class变量不是类型类
【发布时间】:2014-06-03 21:51:47
【问题描述】:

我有一个用于保存数据集合的自定义类。

我在整个代码中都使用这个类,它工作起来很顺利,除了在一个地方,当我需要将类对象传递给一个方法时。这是一些非常基本的代码来演示我所看到的。

public class doSomething
    static void myMethod(customClass_myItem) {}

public class customClass
    public str classMethod() {}

form method
    customClass myItem = new customClass();
    myItem.classMethod(); //this works, so I know the class is good
    doSomething::myMethod(myItem); //Gives error: variable is not of the type CLASS.

我在这里完全迷失了。如果我根本不能使用这个类,我会理解,但是当它传递给另一个方法时它不起作用..没有任何意义。如果我设置断点,调试器会指示 myItem 是正确类型的类。

有什么建议吗?

谢谢

【问题讨论】:

    标签: axapta x++ dynamics-ax-2012


    【解决方案1】:

    您的 myMethod 需要 customClass_myItem(或后代)类的对象,而不是 customClass

    如果您将参数类型更改为object,它应该可以工作。

    static void myMethod(Object o) {}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-21
      • 2015-11-22
      • 1970-01-01
      • 2011-10-21
      • 1970-01-01
      相关资源
      最近更新 更多