I read here it is possible to call another constructor Calling constructor from other constructor in same class
But it calls the other constructor at the beginning, whereas I want to call at the end. Is this possible ?
Update for people asking for specific: In program.cs I want to be able, depending on some context, to do
either this:
// Form1 will show a message from its own private member
Application.Run(new Form1());
or this:
// Form1 will show a message from class1 member (kind of overloading form1 message if class1 exists)
Application.Run(new Form1(new Class1()));
I Form1 I have
private string member = "Test Sample if no class1";
In class1 I have
private string member = "Test Sample from class1";
public string member;
{
get { return this.member; }
set { this.member = value; }
}
In Form1 I have these 2 constructors
// of course Form1() could contain 100 lines of code
Form1() { MessageBox.Show(this.member); }
// I don't want to duplicate 100 lines in second constructor
// so I need to call first constructor
Form1(class1) {
this.member = class1.member;
// this is where I would now like to call Form1()
// but the syntax below doesn't work
this();
}