I don't understand the following phenomenon, could someone explain me please what I got wrong?
public class BaseClass
{
public BaseClass()
{
BaseClass.Instance = this;
}
public static BaseClass Instance
{
get;
private set;
}
}
public class SubClassA : BaseClass
{
public SubClassA()
: base()
{ }
}
public class SubClassB : BaseClass
{
public SubClassB()
: base()
{ }
}
class Program
{
static void Main(string[] args)
{
SubClassA a = new SubClassA();
SubClassB b = new SubClassB();
Console.WriteLine(SubClassA.Instance.GetType());
Console.WriteLine(SubClassB.Instance.GetType());
Console.Read();
}
}
As I understood, the compiler should generate a new Type through inheritance, that SubClassA and SubClassB are really own types with own static variables. But it seems that the static part of the class is not inherited but referenced - what do i get wrong?