Re: Override static derived variable
- From: "Joanna Carter \(TeamB\)" <joannac@xxxxxxxxxxxxxxx>
- Date: Sun, 19 Jun 2005 16:43:41 +0100
"knocte" <knocte@xxxxxxxxxxxxxxxxxxxxxxxx> a écrit dans le message de news:
d93v33$skl$1@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> I have a problem with C# language. I want to define an algorithm on a
> static function inside an abstract class. This function calls a static
> variable inside the same class. Then I want to define some derived
> classes wich inherit the function and override the variable, but it
> doesn't work.
I would have said that you should not override the variable, just the
initialising code in a static constructor.
abstract public class X
{
protected static string var;
protected static SetVar(string value)
{
var = value;
}
static X()
{
SetVar("X");
}
public static void print_my_var()
{
Console.WriteLine("my var is " + var);
}
}
public class A : X
{
static A()
{
SetVar("A");
}
But this doesn't work either as it appears that the only static constructor
to be called in class A is X().
I must admit that this is not as I would have expected. Does anyone know if
this is a bug in beta 1 ?
Joanna
--
Joanna Carter
Consultant Software Engineer
.
- Follow-Ups:
- Re: Override static derived variable
- From: Chad Z. Hower aka Kudzu
- Re: Override static derived variable
- References:
- Override static derived variable
- From: knocte
- Override static derived variable
- Prev by Date: Re: C# COM object not being released
- Next by Date: Re: DateTime Null value in Typed DataSet gives Invalid Cast Exception - Please help !!!
- Previous by thread: Override static derived variable
- Next by thread: Re: Override static derived variable
- Index(es):
Relevant Pages
|
Loading