Tech Off Thread

5 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

C# question - enums and classes declared within a class

Back to Forum: Tech Off
  • User profile image
    Gambit

    I've seen this a few times over the past few weeks and I just have to know what's the point of it. Is there an advantage of doing that at run time?

  • User profile image
    Manip

    Yes. There is.

  • User profile image
    SMac
  • User profile image
    prog_dotnet

    To my knowlege, there are no advantage of doing so at runtime.
    From a design point of view, a class should only describe one entity and can be nested if you have a relationsip between them.
    Classes themself are partitioned into the namespaces wich also can be nested.
    Classes and namespaces are just a logical grouping of your code, The runtime itself works with pysical enteties, aka asseblies.(exe, dlls ..dynamic or static)

    So, you could take some of the classes that are seldomly used, and put them in different modules(files), and link them togheter to an assebly with assebly linker.The dlls containing your classes will only be loaded in memory when necessary.
    ( you can also make your project imports namesapce as small as possible. in vs 2003, vb windows apps imports the system, system.collection, system.data, system.diagnostics, system.drawing, system.windows.forms and microsof.visualbasic )

    Your program starts with the main method, but before main executes, clr detects the types referenced by main and makes an internal structure that contains an entry for each metod. Each entry is the memory location to where the metod can be found.

    When this structure are initializing, clr sends the entries to the JIT Compiler (its just a function of the clr) So the jit knows what methods is called, and searces the metadata tables for the il. The jit compiles the il code to native code and saves it in memory ( this code are saved in memory during the application lifetime, and any other calls to the same code are not compiled but just taken from memory) The jit goes back to the internal data structure, and replace the adress of the called metod (il code), with the adress block of the native code,and then jump to that location. When the code(native) return, the jit returns to the code in Main.

  • User profile image
    Gambit

    SMac wrote:



    That one helped a lot. It also cleared up a mental block I was having in how to do something in one of my programs.

    Thanks for the info everyone

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.