Created
January 24, 2012 04:54
-
-
Save hugodahl/1667920 to your computer and use it in GitHub Desktop.
Constructor confusion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() | |
{ | |
var b = new B(1); | |
} | |
class A | |
{ | |
protected A() | |
{ | |
Console.WriteLine ("A()"); | |
} | |
public A(int val) | |
:this() | |
{ | |
Console.WriteLine ("A({0})", val); | |
} | |
} | |
class B : A | |
{ | |
protected B() | |
{ | |
Console.WriteLine ("B()"); | |
} | |
public B(int val) | |
:base(val) | |
{ | |
Console.WriteLine ("B({0})", val); | |
} | |
} | |
// Define other methods and classes here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A() | |
A(1) | |
B(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment