Notifications
Announcements
No record found.
Hi Friends,
in AX, there is no ref parameter like other language, what's alternative then? If I need to pass something to method, and get updated value back.
Thanks,
*This post is locked for comments
I don't think there is an equivalent as in C#. You can only use out parameters with .NET interoperability. You need to return multiple parameters from a method, you could use a container for that.
You can use static method as single return or multiple return (Container)
Ref: class-> DMFgenerateSSISPackage ->GenerateStagingData
Guys, please, start thinking in objects...
Create an object and safe a reference to a variable. Pass the object to the method, let it modify there and then just access it in the caller method and read the modified state.
When you pass an object, you're really passing just a reference to memory where the object resides. Therefore all references point to the same object and all see any changes you make to it.
Martin,
are you talking about class? or Container is also considered as object.
Classes are object definitions (which instance methods it has, which instance variables etc.). Objects are concrete instances of classes (with specific variable values etc.) saved somewhere in memory.
Container is a value type, not a reference type (= not an object). If you looked into documentation, you would find it very explicit:
In X++, container is one of the primitive types, or value types. container is not a class. A container contains an ordered sequence of primitive values or other containers.
Learning the basics of X++ and object-oriented programming would be very wise.
Hi Martin,
I just want to return a simple integer from method, using class seems to me is overkill.
Also, as others said, using Container to do it, is this something like boxing/unboxing in X+?
It is very simple please create your method return type integer and return the value. I don't know, I am missing anything or not.
Hi Bhaskar,
This is not what I want. Just need to pass parameter.
could I get more inside end to end.
If you "want to return a simple integer from method", just return the integer at the return value, as Bhaskar Roy suggested.
If you want to return a reference, use a reference type, as I suggested. Whether you consider it as a overkill or not is irrelevant.
Boxing/unboxing wouldn't help you in any way.
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Martin Dráb 4 Most Valuable Professional
Priya_K 4
MyDynamicsNAV 2