I'm not so sure you really need a Singleton here, or the use of 'static:
public class RequireMethodInCtor
{
public string Name { set; get; }
public Guid Id { private set; get; }
public RequireMethodInCtor(string name)
{
Name = name;
Id = Guid.NewGuid();
MethodInCtor(this);
}
protected void MethodInCtor(RequireMethodInCtor instance)
{
Console.WriteLine("New instance: {0} Id: {1}", instance.Name, instance.Id.ToString());
}
}
public class Derived1 : RequireMethodInCtor
{
public string SomeString { set; get; }
public Derived1(string name, string somestring) : base(name)
{
SomeString = somestring;
}
}
Create a new instance of 'Derived1, and put a breakpoint in your code before it is executed: when you hit the breakpoint, single-step (F11) and observe what happens.
If you absolutely must call a method in the base Class
after the derived class 'ctor executes whatever initial code:
public class RequireMethodInCtor
{
public string Name { set; get; }
public Guid Id { private set; get; }
public RequireMethodInCtor(string name)
{
Name = name;
Id = Guid.NewGuid();
}
protected void MethodInCtor(RequireMethodInCtor instance)
{
Console.WriteLine("New instance: {0} Id: {1}", instance.Name, instance.Id.ToString());
}
}
public class Derived1 : RequireMethodInCtor
{
public string SomeString { set; get; }
public Derived1(string name, string somestring) : base(name)
{
Name = name;
SomeString = somestring;
base.MethodInCtor(this);
}
}