T
Tim Van Wassenhove
Hello,
When i read the CLI spec, 8.10.2 Method inheritance i read the
following:
"A derived object type inherits all of the instance and virtual methods
of its base object type. It does not inherit constructors or
static methods...."
In the C# spec, 17.2.1 Inheritance i read the following:
"A class inherits the members of its direct base class. Inheritance means
that a class implicitly contains all members of its direct base class,
except for the instance constructors, finalizers, and static constructors
of the base class"
Consider the following code:
class A { public static void Method1() { } public static int X = 5;}
class B : A { }
Now i call B.Method1, which is translated to a call A.Method1 in IL.
The C# spec seems to mention that "static" means that members are
related to a specific type, instead of instances...
If C# really inherits all members, wouldn't that mean that the following
code should output 5 instead of the 10?
B.X = 10; Console.WriteLine(A.X);
To come to my question: Am i right when i say that in C# there isn't
true inheritance of static members?
When i read the CLI spec, 8.10.2 Method inheritance i read the
following:
"A derived object type inherits all of the instance and virtual methods
of its base object type. It does not inherit constructors or
static methods...."
In the C# spec, 17.2.1 Inheritance i read the following:
"A class inherits the members of its direct base class. Inheritance means
that a class implicitly contains all members of its direct base class,
except for the instance constructors, finalizers, and static constructors
of the base class"
Consider the following code:
class A { public static void Method1() { } public static int X = 5;}
class B : A { }
Now i call B.Method1, which is translated to a call A.Method1 in IL.
The C# spec seems to mention that "static" means that members are
related to a specific type, instead of instances...
If C# really inherits all members, wouldn't that mean that the following
code should output 5 instead of the 10?
B.X = 10; Console.WriteLine(A.X);
To come to my question: Am i right when i say that in C# there isn't
true inheritance of static members?