I want to do something like this
public class Class1 { public Class1() { } public Class1(int a) { } } public class Class2 :Class1 { public Class2(int a) { } public Class2(): base(2) { this(2); // new Class2(2); } }
I know this cannot be achieved in Java (you can use one of (super or this) in the first line)
But for some reason I need such work, how to do it? A tool that calls the constructor with the parameterized and derived classes of the base class in the default constructor of the derived class.
The MSDN article on designers is pretty good. Here are a few relevant bits:
base ....., . , , , .
:
public class Class1 { public Class1() { } public Class1(int a) { } } public class Class2 :Class1 { public Class2(int a) : base(a) { } public Class2(): this(2) { } }
- , . : . .
. - , , . ( , , .) , . , , .
, "master" () . - , , . - , , , , . "master" . , , , .
, "" , ... , . factory , , / - , TimeSpan.FromMinutes.
TimeSpan.FromMinutes
( ). - - , . .