Skip to content

Instantly share code, notes, and snippets.

@hugodahl
Created January 24, 2012 04:54
Show Gist options
  • Save hugodahl/1667920 to your computer and use it in GitHub Desktop.
Save hugodahl/1667920 to your computer and use it in GitHub Desktop.
Constructor confusion
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
A()
A(1)
B(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment