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)

Diference between main method and class declaration

(0) ShareShare
ReportReport
Posted on by

hi everyone.

I don't have much time working with ax and I'm a bit confused about what is "class declaration" and "main method"

as far as i know, in poo the main method is where you start running your application and control the class behavior, I guess this doesn't change in ax but what is class declaration then?

I mean, when first started, I've been told that the class declaration was the first thing that runs and after the methods of it and control's class behavior, so I took from granted that it was some sort of synonym for the main method, since I didn't found at the time classes with them, now i found a class that has main method and class declaration and I don't get how this operates and neither had found something on web that explains what's the difference.

i hope i made myself clear

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Mea_ Profile Picture
    60,284 on at

    Hi luis torres,

    You are correct saying that main method is an entry point. So whenever you open menu item it executes main method that is static. However, you may not have a main method in the class, like you don't need them in C#. Class declaration is a place where you declare class, set it's access modifier, declare variables etc., you could not have any code there because it's just a declaration.

  • Community Member Profile Picture
    on at

    so, let me see if i'm getting it right, main method works exactly as any other poo languaje, and class declaration is just to define another class, it doesn't do anything unless the constructor is called.

  • Verified answer
    Mea_ Profile Picture
    60,284 on at

    Yes, so in c sharp class declaration looks like:

    public class Rectangle {

      float length;

      float width;

    }

    And it does nothing, same in AX, just a place to declare variables, say what you extending, etc.

    In c sharp main() is entry point of your program. In AX it is entry point for class when you call it though menu item, AX automatically executes main and pass some information to Args parameter.  If you run class from AOT AX would call main as well.

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
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Sukrut Parab Profile Picture

Sukrut Parab 2 Moderator

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans