web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Blogs / DaxGeek / Scoping and Parameters in X++

Scoping and Parameters in X++

Hossein.K Profile Picture Hossein.K 6,648
In X++ variables and methods are within a well-defined scope. A scope is the
area where an item is accessed.
Scopes in X++Instance variables, declared in class declarations, can be accessed from any
methods in the class, and from methods in sub-classes that extend the class.
Local variables can be accessed only in the method in which they are defined.

1:  public class ANewClass  
2: {
3: int abc;
4: }
5: private void aNewMethod()
6: {
7: int xyz;
8: }
Variable abc is declared in the classDeclaration of ANewClass and variable xyzis declared in aNewMethod. The variable xyz can only be used within the scope
of the method
aNewMethod, but the variable abc can be accessed by all methods
in the class.


Best Regards,
Hossein Karimi

Comments

*This post is locked for comments