X++ in AX7: Internal keyword


internal is a new keyword in X++. It has the same semantics as in C#.

When you mark a class or method as internal, then it can only be accessed from within the model where it is defined.

internal class MyInternalClass 
{  
    internal void myInternalMethod() 
    {  
    }  
}

Notice, you can define internal methods on public classes too.

 

THIS POST APPLIES TO MICROSOFT DYNAMICS AX7 TECHICAL PREVIEW; IS PROVIDED AS-IS AND CONFERS NO RIGHTS.

Comments (6)

  1. Midhun PS says:

    Hi,
    Suppose if i want to access an internal method present in an internal class, outside, what should i do?
    can anyone help?

    1. You cannot access internal methods from “the outside”. That is the whole point of internal. One option would be to log an extension request with Microsoft.
      Please keep in mind that, if the method is “internal protected”, then you can override it.

  2. Evaldas L says:

    Thanks, that makes sense. However, I still believe it will not be used often 🙂

  3. Volker Deuss says:

    Hi Michael,

    it should be "…within the package where it is defined." to be more precise, right? Or am I confusing this? Or did you choose to be a little inaccurate in order to avoid confusion amongst those who are new to AX7? 🙂

    Cheers

  4. Good question Evaldas 🙂

    Here is one example:

    If you are building a library, you can use the internal keyword to hide types you don't want to expose. This will give a sharply defined API for your consumers, and lower the responsibility on you on backwards compatibility – internal classes are yours to control, change, delete, etc.

  5. Evaldas L says:

    What's the use of it?

Skip to main content