Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Diference between main method and class declaration

Posted on by Microsoft Employee

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

  • Verified answer
    Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: Diference between main method and class declaration

    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.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Diference between main method and class declaration

    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.

  • Suggested answer
    Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: Diference between main method and class declaration

    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.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans