static class console and no inherited

  • Thread starter Thread starter Hex
  • Start date Start date
H

Hex

public static class Console
Member of System

Summary:
Represents the standard input, output, and error streams for console
applications. This class cannot be inherited.

My question is : Why a static class can not be inherited by another
static class ?

thx in advance claudio
 
public static class Console
Member of System

Summary:
Represents the standard input, output, and error streams for console
applications. This class cannot be inherited.

My question is : Why a static class can not be inherited by another
static class ?

The language was defined that way.

And it is worth noting that at the IL level the class
is actually sealed.

But I assume that you really want to know why it was designed
this way.

My guess is that it is because it would not provide
much value without making things very complex.

What makes inheritance and interface implementation
really useful for non static classes is the
polymorphism.

That is not possible in the same way for static
classes.

Too little value for too many complications.

Arne
 
C# follows the same design as most other mainstream OOP languages (and
especially C-based ones such as C++ and Java), where static class
members are accessible only implicitly from within the class itself, or
by specifically naming the type in which the static member exists.

That is how C# does it.

Both C++ and Java allows you to call static methods "on"
an instance.

Arne
 
Back
Top