Skip to content

Instantly share code, notes, and snippets.

@snippe
Created November 10, 2014 11:48
Show Gist options
  • Save snippe/5b55b326e337f892d81d to your computer and use it in GitHub Desktop.
Save snippe/5b55b326e337f892d81d to your computer and use it in GitHub Desktop.
class X
{
protected virtual void F() { Console.WriteLine("X.F"); }
protected virtual void F2() { Console.WriteLine("X.F2"); }
}
class Y : X
{
sealed protected override void F() { Console.WriteLine("Y.F"); }
protected override void F2() { Console.WriteLine("Y.F2"); }
}
class Z : Y
{
// Attempting to override F causes compiler error CS0239.
// protected override void F() { Console.WriteLine("C.F"); }
// Overriding F2 is allowed.
protected override void F2() { Console.WriteLine("Z.F2"); }
}
class A {}
sealed class B : A {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment