Re: Override static derived variable



Jon Skeet [C# MVP] <skeet@xxxxxxxxx> wrote in
news:MPG.1d1faede6caac18298c351@xxxxxxxxxxxxxxxxxxxx:
> Those both compile to the same thing - there will be nothing which
> actually references Derived.GetVar in the IL, as there is really no
> such method. Therefore there is (as far as the CLR is concerned) no
> need to initialise the Derived class.

Joanna,

I'll add a bit to Jon's reply since I know you have a Delphi background.

..NET does NOT load a class until it is ACTUALLY used. So the static constructor for a given class
will not be called, until the class is actually needed. All classes are load on demand, vs
Delphi where the units get their initialization sections called on start up of the application.


--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Develop ASP.NET applications easier and in less time:
http://www.atozed.com/IntraWeb/
.



Relevant Pages

  • Re: Override static derived variable
    ... > I'll add a bit to Jon's reply since I know you have a Delphi background. ... > .NET does NOT load a class until it is ACTUALLY used. ... private static string var; ... public static string GetVar() ...
    (microsoft.public.dotnet.languages.csharp)
  • LISA
    ... In MS Fox Pro gibts das Lisa Prinzip = Load, Initialise, Activate ... In VS gibts ja nur Load, und anschließend Activate. ... wann werden diese Methoden und in welcher Reihenfolge geladen? ...
    (microsoft.public.de.german.entwickler.dotnet.csharp)
  • Re: Runtime errors on certain machines - HELP!!!
    ... When you're loading a Form using "Load" then only the Initialise and Load events will trigger, but any code in either of those events might cause them to trigger in a different order and might also cause other Form events to also trigger, depending on the code. ... try placing Exit Sub as the very first line in both the Load and the Initialise events of frmMain. ...
    (microsoft.public.vb.general.discussion)
  • Best Windows based dvd player?
    ... Have downloaded a trial of Intervideo's Windvd7, but it's just too big, and ... takes too long to load and initialise. ... I'm running DVD Region Free + Css to get round the limited ...
    (uk.media.dvd)
  • Re: ExceptionInInitializerError: NullPointerException
    ... >>If the class it tries to load has an eagerly initialized static field ... > static that did not initialise until a B object was created, ... It doesn't depend on allocating objects of B. But, ...
    (comp.lang.java.programmer)