“此"与“元素"对比X ++中的关键字 [英] "this" vs. "element" keyword in X++
问题描述
在X ++中编写代码时,有时需要引用this.functionYouWant()
,有时则是element.FunctionYouWant()
.有时两者都在范围内.我经常尝试一种,如果我想要的功能不存在,我会尝试另一种.是否有规则说明何时使用this
和何时使用element
?
When writing code in X++ you sometimes need to reference this.functionYouWant()
and sometimes it is element.FunctionYouWant()
. Sometimes both are in scope. I often try one and if the function I want isn't there I try the other. Is there a rule that explains when to use this
and when to use element
?
推荐答案
this
可以在任何对象中用于引用当前对象和成员方法.
this
can be used in any objects to reference the current object and member methods.
MorphX表单和报表是复合对象.
MorphX forms and reports are composite objects.
在表单中,对象的集合包含在FormRun
对象中.您可以使用element
引用来引用外部FormRun
对象中的成员.
In forms the collection of objects is contained within a FormRun
object. You can reference members in the outer FormRun
object by using the element
reference.
如果将代码放在顶层,则this
和element
之间没有功能上的区别.
If your code is placed at the top level there are no functional difference between this
and element
.
如果将代码放置在FormDataSource中,则this
将引用数据源,而element
将引用FormRun
.
If your code is placed in a FormDataSource this
will reference the datasource but element
will reference the FormRun
.
这篇关于“此"与“元素"对比X ++中的关键字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!