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 :
Microsoft Dynamics AX (Archived)

X++ equivalent to C#'s out parameter

(0) ShareShare
ReportReport
Posted on by 1,450

Is there an X++ equivalent to C#'s out parameter? msdn.microsoft.com/.../t3c3bfhx.aspx

If not, what is best practices for returning multiple parameters from a method call? Container?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Dick Wenning Profile Picture
    8,705 Moderator on at

    in case of returning multiple parameter. try this

    container whatever()

    {

       return ['a',34'];

    }

  • Suggested answer
    Community Member Profile Picture
    on at

    No X++ is not having out parameter equivalent to C#

    Yes if you what a method to return multiple variable you need to return Container from the method.

  • Suggested answer
    Tommy Skaue Profile Picture
    Moderator on at

    I don't think there is none, in the same way as C#. The same applies to pointing a method as a parameter. Some of the constructs from C# not yet in X++.

    May I ask why you want the out modifier?

    About out:

    msdn.microsoft.com/.../t3c3bfhx.aspx

    About passing values by reference in X++ compared to C#:

    msdn.microsoft.com/.../cc586700.aspx

  • Verified answer
    Martin Dráb Profile Picture
    237,801 Most Valuable Professional on at

    X++ supports byref keyword which can be used for out parameters (out and ref in C# are almost identical), but only in the context of .NET Interop. See How to: Use the byref Keyword for CLR Interop for details.

    Object oriented programming use objects for grouping related data. It's much safer using a specialized object than weakly-typed containers, because the code is more readable and types are checked by compiler. It's also generally more efficient to pass a mere reference than all data. There may be a situation when you want to use a container, mainly when you want to transfer the data across tiers (e.g. from server to client), but then it's better if you implement pack() and unpack() for your class, hide serialization details there and use passing by reference or by serialized value as needed.

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.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans