Re: Override static derived variable



"Chad Z. Hower aka Kudzu" <cpub@xxxxxxxxx> a écrit dans le message de news:
Xns967AC7FE3592Dcpubhowerorg@xxxxxxxxxxxx

> 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.

Unfortunately, I now understand that bit :-(

But the good news is that I have solved the OP's problem. All you have to do
is to re-declare the GetVar() static method and call the base method !!

class Thing
{
private static string var;

protected static void SetVar(string value)
{
var = value;
}

static Thing()
{
SetVar("Thing");
}

public static string GetVar()
{
return var;
}
}

class Derived : Thing
{
static Derived()
{
SetVar("Derived");
}

public static new string GetVar()
{
return Thing.GetVar();
}
}

Yeeesss !!!

Joanna

--
Joanna Carter (TeamB)

Consultant Software Engineer
TeamBUG support for UK-BUG
TeamMM support for ModelMaker


.



Relevant Pages

  • Re: Page Structure
    ... The page contains a header and left column that remain constant. ... I load a variable according to which the contents of is called. ... Load b.php (left column info) ... (if $var is "elephants" include elephanttext.php) ...
    (comp.lang.php)
  • Page Structure
    ... Load a.php ... Load b.php (left column info) ... (if $var is "elephants" include elephanttext.php) ... (if $var is "tigers" include liontext.php) ...
    (comp.lang.php)
  • Re: Compiler directive for win98?
    ... Load the function within your own code instead of linking to it directly. ... Take a look at the TlHelp32 unit for examples of loading functions at run time. ... var Info: TOSVersionInfoA; ...
    (alt.comp.lang.borland-delphi)
  • Re: Override static derived variable
    ... > actually references Derived.GetVar in the IL, ... > need to initialise the Derived class. ... 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. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: small script question. need proper syntax
    ... (all I want is the proper way to sent it ... below it would at least load one image that I define as a default image. ... var Wvalue= ...
    (microsoft.public.frontpage.client)